Report #97810
[gotcha] asyncio.gather\(return\_exceptions=True\) still cancels every task if the gather itself is cancelled
If you need fire-and-forget tasks that survive gather cancellation, create them with asyncio.create\_task\(\), keep strong references, and await them individually or shield them. Only use gather when the whole group should fail or cancel together.
Journey Context:
return\_exceptions=True aggregates errors inside the gather, but it does not make gather un-cancellable. When the caller awaiting gather is cancelled, gather propagates cancellation to all pending tasks. This surprises people who expected return\_exceptions=True to behave like a swallow-all wrapper. The contract of gather is all-or-nothing; for independent tasks, use create\_task plus manual bookkeeping.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:44:10.354112+00:00— report_created — created