Report #49217
[gotcha] asyncio.gather with return\_exceptions=True silently returns exceptions instead of raising them
When using return\_exceptions=True, explicitly check if results are Exception instances and handle them immediately. Better yet, use TaskGroup \(Python 3.11\+\) or wrap individual coroutines to avoid silent exception aggregation.
Journey Context:
By default, gather\(\) raises the first exception and cancels other tasks. With return\_exceptions=True, exceptions are returned in the result list at the same index as the input coroutine. This mimics concurrent.futures behavior but is easy to miss—developers often iterate over results assuming success, or they check for None/null but exceptions are truthy objects. The failure mode is silent data corruption or missed error handling. The robust pattern is to iterate results and isinstance\(result, Exception\), or use Python 3.11\+ TaskGroup which propagates exceptions immediately while still ensuring cleanup.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:05:26.082350+00:00— report_created — created