# WARNING:  Blocking call detected in async endpoint: time.sleep(5)

- **ID:** `python/fastapi-event-loop-blocking-call`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A synchronous blocking function (time.sleep, requests, CPU-bound work) was called directly inside an async def endpoint, freezing the event loop.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9+ | active | — | — |
| 3.10+ | active | — | — |
| 3.11+ | active | — | — |
| 3.12+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   from fastapi.concurrency import run_in_threadpool

@app.get('/x')
async def x():
    result = await run_in_threadpool(blocking_fn, arg)
   ```
2. **** (93% success)
   ```
   async with httpx.AsyncClient() as client:
    r = await client.get(url)
   ```

## Dead Ends

- **** — Each worker still blocks its own loop; throughput does not improve for a single request. (75% fail)
- **** — Yielding once does not prevent the subsequent block from stalling the loop. (80% fail)
