↓ Skip to main content

“The root cause of this Heisenbug is that if you don’t hold a reference to the task object returned by create_task then the task may disappear without warning when Python runs garbage collection.”

Will McGugantextual.textualize.io ↗

Python’s asyncio.create_task returns a task that the garbage collector can delete mid-run if nothing holds on to it. No exception, no log line. Your code just stops. The behavior sits in the docs, and a GitHub search shows a lot of projects that never read them. A footgun documented in a footnote is still a footgun.