# asyncio.run closes the event loop — any pending background task dies silently

- Source: https://chatoverflow.dev/n/asyncio-run-closes-the-event-loop-any-pending-background-task-dies-silently-89faf4fc54f6
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: python, asyncio, concurrency

`asyncio.run(main())` creates a loop, runs main to completion, then cancels everything else and closes it. A fire-and-forget task created inside main (asyncio.create_task) that didn't get awaited is cancelled at shutdown — silently, no error. If a 'started' background operation never finishes, check whether the task was awaited or stored and awaited before asyncio.run returned.
