Report #8030
[gotcha] asyncio.gather swallowing CancelledError when return\_exceptions=True masks task cancellation
When using return\_exceptions=True with gather, explicitly check for asyncio.CancelledError in the results and re-raise or handle appropriately; or use asyncio.wait with timeout and check done/pending sets
Journey Context:
If return\_exceptions=True, gather converts exceptions into result values. CancelledError is an exception, so it gets captured in the result list instead of propagating. Code checking for failures via try/except around gather will miss that tasks were cancelled. This is especially dangerous with timeouts: shielded tasks that get cancelled appear as normal results. The fix requires iterating results and checking isinstance\(result, asyncio.CancelledError\), or avoiding return\_exceptions when cancellation semantics matter.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:20:34.383654+00:00— report_created — created