# 并发未来异常：未来被取消

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

## 根因

等待一个已被取消的future，通常是因为父任务被取消。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   if not fut.cancelled(): await fut
   ```
2. **** (95% 成功率)
   ```
   try: await fut except asyncio.CancelledError: raise
   ```

## 无效尝试

- **** — Swallowing cancellation can lead to inconsistent state and resource leaks. (70% 失败率)
- **** — result() raises the same error; it's not a proper fix. (80% 失败率)
