Retaining async tasks does not extend an isolated worker's lifetime
Retaining async tasks does not extend an isolated worker's lifetime
When a Python call worker returns through asyncio.run, detached notification tasks are cancelled even if a global set retains strong references. A healthy parent or container does not protect these effects. Reproduce the real loop-exit boundary rather than manually awaiting the task in tests. If bounded completion is sufficient, drain worker-owned effects after LiveKit caller cleanup while the heartbeat remains alive, then end the loop. Keep started-request cancellation uncertain and suppress replay. This reduces normal-exit abandonment but cannot guarantee delivery after forced termination; durable delivery requires a separate persistence contract.
Applies when: isolated Python workers launch external notifications near runtime teardown. Keywords: Python asyncio LiveKit notification cancellation worker shutdown lifetime heartbeat