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

Asyncio Support #2

Closed
ethanleifer opened this issue Sep 6, 2022 · 4 comments · Fixed by #11
Closed

Asyncio Support #2

ethanleifer opened this issue Sep 6, 2022 · 4 comments · Fixed by #11

Comments

@ethanleifer
Copy link

Does wakaq support async tasks?

@alanhamlett
Copy link
Member

Dunno, never tried. All my tasks are sync.

@alanhamlett
Copy link
Member

alanhamlett commented Sep 18, 2023

Calling async functions from WakaQ tasks works with this behavior:

  • if you call await the task won't finish until the async function completes
  • if you don't use await, the task will finish and the worker process will consume a new task while still running the async code in the same process

Task timeouts aren't supported for async code without using await.

Currently the only way to run async code in a WakaQ task is converting an async function to sync. Running an async function without await from non-async code means there's no async event loop and the async function never actually executes.

@alanhamlett
Copy link
Member

More info in this stackoverflow about using asgiref to run async functions from synchronous tasks. It's about Celery, but it also applies to WakaQ.

@alanhamlett
Copy link
Member

Added async task support in v3.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants