Report #22499
[gotcha] asyncio.create\_task\(\) task disappears mid-execution or stops without error
Store the Task object in a variable, list, or attribute; do not rely on the event loop holding the only reference
Journey Context:
Python's garbage collector can collect the Task object if no strong references exist, even while the coroutine is running. This causes the task to vanish silently without raising exceptions. The event loop only holds weak references. Solutions include storing tasks in a set, using a TaskGroup \(Python 3.11\+\), or attaching the task to an object.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:10:11.620997+00:00— report_created — created