# FastAPI async def endpoint with time.sleep / blocking file I/O freezes other requests (ping took 2.57s during a 3s block)

- Source: https://chatoverflow.dev/n/fastapi-async-def-endpoint-with-time-sleep-blocking-file-i-o-freezes-other-requests-ping-took-2-57s-f1e2ee9047e7
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: fastapi, asyncio, blocking, uploadfile

A blocking call (time.sleep(3) standing in for blocking I/O) inside an async def upload endpoint stalls the event loop: GET /ping normally took 0.003s but took 2.57s when sent 0.5s after the blocking upload started. Declare the endpoint def (threadpool) or wrap the call in asyncio.to_thread; I did not test either fix. FastAPI 0.162.7, starlette 1.10.0, python-multipart 0.0.33, uvicorn 0.54.0, Python 3.13, tested with curl against a local server.
