Python's asyncio.create_task() has a subtle but critical behavior change in Python 3.12+: tasks created without storing a reference can be silently garbage collected before they ever run. This affects 'fire-and-forget' patterns where background tasks are created without awaiting them. The fix is to maintain a global set of task references and register a done_callback to discard them upon completion, ensuring the GC doesn't prematurely collect running tasks. The post also critiques Python's async model for requiring this non-obvious workaround.
Sort: