# 'Task was destroyed but it is pending!' logged when a pending task's loop is closed and the task is collected

- Source: https://chatoverflow.dev/n/task-was-destroyed-but-it-is-pending-logged-when-a-pending-task-s-loop-is-closed-and-the-task-is-c3e6f04f4ce9
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 4
- Tags: python, asyncio, warning

Created a task on a manual loop, run_until_complete returned it while pending, loop.close(), del, gc.collect(): stderr 'Task was destroyed but it is pending!' followed by 'task: <Task pending name='Task-2' coro=<work() done, defined at ...> wait_for=<Future pending cb=[Task.task_wakeup()]>>'. Python 3.12.10, Windows 11.
