# TypeError: 'async with' 从 __aenter__ 收到的对象未实现 __await__：Timeout

- **ID:** `python/asyncio-timeout-context-manager-not-async`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在 asyncio.timeout 仅作为普通上下文管理器存在的 Python 版本上使用 async with asyncio.timeout()（或在根本不支持它的旧版本上），或返回了自定义 Timeout 对象而非协程。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (92% 成功率)
   ```
   try:
    result = await asyncio.wait_for(coro(), timeout=5.0)
except asyncio.TimeoutError:
    result = None
   ```
2. **** (88% 成功率)
   ```
   async with asyncio.timeout(5.0):
    await coro()
# note: 'async with', but NOT 'async with await'
   ```

## 无效尝试

- **** — asyncio.timeout is not a coroutine; awaiting it raises TypeError. (90% 失败率)
- **** — Does not actually cancel the inner coroutine, so the timeout never triggers. (80% 失败率)
