Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Use AsyncDispatcher as class decorator (API) #23721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hlouzada
Copy link
Contributor

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)

Fix typings issue with AsyncDispatcher, refactor to use as decorator and add minor improvements on logic for performace.

New Usage:

Non-Blocking usage (returns a concurrent Future):

@AsyncDispatcher()
async def my_coroutine(...):
    ...

future = my_coroutine(...)  # Non-blocking call

result = future.result()  # Blocking call

Blocking usage (returns the result):

@AsyncDispatcher(early_return=False)
async def my_coroutine(...):
    ...

result = my_coroutine(...)  # Blocking call

Coroutine usage (returns an awaitable Future):

@AsyncDispatcher(return_awaitable=True)
async def my_coroutine(...):
    ...

result = await my_coroutine(...)  # Wait for the result to be ready

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: @hlouzada

@ccordoba12 ccordoba12 changed the title Use AsyncDispatcher as Class Decorator PR: Use AsyncDispatcher as class decorator (API) Feb 13, 2025
@ccordoba12 ccordoba12 added this to the v6.1.0 milestone Feb 13, 2025
@ccordoba12 ccordoba12 changed the title PR: Use AsyncDispatcher as class decorator (API) PR: Use AsyncDispatcher as class decorator (API) Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants