Report #54956
[gotcha] asyncio.gather\(\) with return\_exceptions=True still raises CancelledError if the gather itself is cancelled
Wrap the gather in try/except CancelledError or use shield\(\) on the awaitables if you need to distinguish between subtask failure and outer cancellation
Journey Context:
People assume return\_exceptions=True makes gather swallow all exceptions, but CancelledError from the outer scope cancellation is not considered a 'subtask exception'—it is a control flow mechanism to abort the entire operation. You must handle it separately or use asyncio.shield\(\) to prevent propagation of cancellation to the gather itself.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:44:17.199071+00:00— report_created — created