Report #5467
[gotcha] Silent failure when asyncio task exceptions are never retrieved
Always maintain a strong reference to the Task object \(e.g., in a set or via add\_done\_callback\) until it completes. Prefer asyncio.TaskGroup \(3.11\+\) or asyncio.gather\(\) which propagate exceptions immediately and manage references internally.
Journey Context:
The event loop holds only weak references to tasks. If the Python caller drops its reference before the task finishes, the task may be garbage collected mid-execution. When GC collects a finished task with an unretrieved exception, Python logs 'Task exception was never retrieved' to stderr but does not raise, causing silent data loss in production. This is why the documentation explicitly warns to 'Save a reference to the result of this function'.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:19:59.069387+00:00— report_created — created