示例工程 18-asyncio-event-loop
18-asyncio-event-loop/05-gather-cancel/README.md
# 05 · gather-cancel
**演示**:`asyncio.gather` 中一个任务抛错时,`gather` 立即把异常抛给调用方,但**不会取消**兄弟任务;兄弟继续跑完。结构化并发应使用 3.11+ 的 `TaskGroup`(第 20 章)。
**运行**:
```sh
uv run python examples/18-asyncio-event-loop/05-gather-cancel/gather_cancel.py
```
**预期输出**(3.12.9):
```text
pending after error: (True, True)
results: ['a', 'b']
siblings_cancelled: (False, False)
```
**依赖**:仅标准库。
**注意**:示例在 `gather` 抛错后显式 `await asyncio.sleep(0.06)` 等兄弟完成,否则事件循环关闭时它们会被取消并可能产生警告。