GunicornDjango

Synchronous blocking calls prevent cancellation in async views

warning
performanceUpdated Mar 1, 2026(via Exa)
How to detect:

When synchronous blocking calls (like standard Django ORM operations) are executed inside async views, the code cannot receive cancellation signals from Uvicorn until the blocking call finishes. This prevents the application from stopping execution when the client disconnects, continuing to waste resources on abandoned requests.

Recommended action:

Use truly asynchronous code with await statements. Wrap external calls and database queries with asyncio.wait_for timeouts. For Django ORM, use async-compatible database operations or wrap synchronous calls appropriately. Ensure long-running loops and queries are interruptible by the async runtime.