You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example in README shows how to queue a task with sync .delay() function, which is not a good idea in async handler.
We have remote IO there: usually low-latency, but no warranty. So .delay() blocks asyncio loop when called from async route.
task=create_task(make_dinner.delay(...))
# make something else here in the meanwhile# ...# ensure the task was enqueued before the request has been finalizedawaittask
@rushilsrivastava thank you for your interest in contributing to the project and my apologies for the delayed response. I'd be open to reviewing a PR. Please go ahead and submit it, and I'll take a look as soon as possible.
The example in README shows how to queue a task with sync
.delay()
function, which is not a good idea in async handler.We have remote IO there: usually low-latency, but no warranty. So
.delay()
blocks asyncio loop when called from async route.README presents examples with async routes calling sync
.delay()
call example (e.g. "https://github.com/Adori/fastapi-cloud-tasks#local"). This might be misleading for a less experienced user.Making
.delay(...)
async would allow to callor even
Cloud Tasks library already provides async variant of the client for some time, and it works well:
https://cloud.google.com/python/docs/reference/cloudtasks/latest/google.cloud.tasks_v2.services.cloud_tasks.CloudTasksAsyncClient
The text was updated successfully, but these errors were encountered: