FastAPI asynchronous background tasks blocks other requests?
Your task is defined as async, which means fastapi (or rather starlette) will run it in the asyncio event loop. And because somelongcomputation is synchronous (i.e. not waiting on some IO, but doing computation) it will block the event loop as long as it is running. I see a few ways of solving this: Use … Read more