Report #52153
[gotcha] asyncio.gather with return\_exceptions=True silently swallows CancelledError preventing task cancellation
Do not use return\_exceptions=True if you need cancellation to propagate; explicitly check for CancelledError in results and re-raise, or use TaskGroup \(Python 3.11\+\) which handles this correctly by design.
Journey Context:
Before Python 3.11, CancelledError inherited from Exception, not BaseException. When return\_exceptions=True, gather\(\) catches Exception to wrap results in the returned list, inadvertently catching CancelledError and treating it as a returned value rather than propagating the cancellation. This silently breaks cancellation chains and can cause tasks to continue running after cancellation was requested. The fix in 3.11 moved CancelledError to BaseException, but for older versions or explicit compatibility, avoid return\_exceptions=True in cancellable contexts or manually scan results for CancelledError and re-raise.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:02:06.712272+00:00— report_created — created