# 警告：事件循环被阻塞，异步路由中检测到阻塞调用，事件循环停滞 5.2 秒。

- **ID:** `python/fastapi-async-route-blocking-event-loop`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

`async def` 路由直接调用了同步/阻塞函数（requests、time.sleep、重 CPU 操作），冻结了事件循环。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 0.100.x | active | — | — |
| 0.110.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Use httpx.AsyncClient: `async with httpx.AsyncClient() as c: r = await c.get(url)`
   ```
2. **** (90% 成功率)
   ```
   Offload with `await asyncio.to_thread(blocking_fn, args)` or `run_in_executor`.
   ```

## 无效尝试

- **** — Each worker still blocks its own loop under load. (80% 失败率)
- **** — Does not yield for blocking I/O; loop still stalls. (90% 失败率)
