# asyncio异常：任务异常从未被检索

- **ID:** `python/asyncio-task-exception-silent`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

任务引发异常，但异常从未被等待或检索，导致静默失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.7 | active | — | — |
| 3.8 | active | — | — |
| 3.9 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
   ```
2. **** (95% 成功率)
   ```
   try: await task except Exception as e: print(e)
   ```

## 无效尝试

- **** — The exception is lost, making debugging difficult. (90% 失败率)
- **** — If the task is not done, it may block or raise. (60% 失败率)
