Report #17815
[gotcha] Asyncio task exception never retrieved / background task fails silently
Always await tasks or call task.result\(\) to surface exceptions; use asyncio.gather\(return\_exceptions=True\) for groups, or add done\_callbacks that check if task.exception\(\) is not None.
Journey Context:
Fire-and-forget tasks don't propagate exceptions to the caller. The exception is stored in the task object and only raised when you await it or call result\(\). If the task is garbage collected with an unretrieved exception, Python logs a 'Task exception was never retrieved' warning, but the program continues. This creates Heisenbugs in concurrent code. The fix requires explicit synchronization points to inspect task outcomes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:24:36.955897+00:00— report_created — created