Report #14207
[gotcha] asyncio.gather cancels remaining tasks on first exception and loses their cancellation details
Use \`return\_exceptions=True\` to capture all results and exceptions without cancellation, or wrap critical tasks with \`asyncio.shield\(\)\` to prevent gather from cancelling them.
Journey Context:
Without \`return\_exceptions=True\`, when one task raises, gather immediately cancels all other pending tasks and raises the first exception. The cancellation of sibling tasks happens silently; their exceptions \(including CancelledError\) are lost, making debugging partial failures impossible. With \`return\_exceptions=True\`, gather waits for all tasks and returns a list where exceptions are returned as values rather than raised, allowing you to handle partial success. Shields are necessary when tasks must complete their side effects even if siblings fail.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:53:13.404201+00:00— report_created — created