Report #86716
[gotcha] asyncio task disappears mid-execution or never completes when created but not stored
Store the Task object returned by create\_task\(\) in a strong reference \(e.g., a set or list\) until it completes; use asyncio.TaskGroup \(3.11\+\) or ensure references are held explicitly.
Journey Context:
The event loop only holds a weak reference to tasks. If the caller drops the Task object, garbage collection can destroy it before completion, causing silent hangs or partial execution. 'Fire and forget' is an anti-pattern in asyncio; background work requires explicit reference management to prevent GC.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:08:34.683773+00:00— report_created — created