|
|
|
|
|
by mivade
1962 days ago
|
|
My understanding was that if you write a regular function (`def` rather than `async def`) then FastAPI (or really Starlette which it uses under the hood) executes the function in a thread pool so that no blocking of the main event loop should occur. |
|
def blocking(): time.sleep(5)
@app.get("/") async def index(): blocking()
The `blocking` function will blocking the event loop. This is something you need to be aware of. Gist with a few scenarios: https://gist.github.com/lukin0110/0074ec5325224674010193bb95...