Async background task block main event loop #2973
Unanswered
benjamin-callonnec
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have my uvicorn server running my FastAPI application.
I have an endpoint which has an asynchronous background task. I observed that running the background task in the main event loop of uvicorn cause the event loop to be blocked while waiting for the background task to finish.
One solution i implemented is to consistently run the background task in a dedicated thread.
https://github.com/encode/starlette/blob/6ee94f2cac955eeae68d2898a8dec8cf17b48736/starlette/background.py#L27
Linked PR: #2974
Beta Was this translation helpful? Give feedback.
All reactions