# 03 · def-vs-async-def **演示**:FastAPI 把 `def` 路由丢进线程池,3 个并发约 0.07s;`async def` 里 `time.sleep(0.05)` 会阻塞事件循环,3 个变串行约 0.17s;改成 `await asyncio.sleep` 恢复并发约 0.05s。 **运行**: ```sh uv run python examples/35-asgi-fastapi/03-def-vs-async-def/def_vs_async_def.py ``` **预期输出**(3.12.9,耗时随机器波动): ```text sync: 0.07s async_block: 0.17s async_sleep: 0.05s sync_concurrent: True async_block_serial: True async_sleep_concurrent: True ``` **依赖**:`uv sync --group service`(fastapi/httpx)。 **注意**:`async def` 不会自动把阻塞调用变异步;阻塞 IO 要么改异步库,要么用 `asyncio.to_thread` 显式卸载。