This is done by adding them to a set and removing them when the task
is done. asyncio itself only keeps a weak references to all tasks. A
task can therefore be destroyed when it is not referenced anymore.
When this happens, we get things like that:
task: <Task pending name='Task-326' coro=<_AIOPubSub.queue_handler.<locals>.handler_coroutine() done, defined at /usr/lib/python3/dist-packages/i3ipc/aio/connection.py:30> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f9f08a13be0>()]>>
This seldomly happens and I still have a hard time understanding the
exact cause.
To workaround that, we provide a tiny wrapper around ensure_future()
keeping a reference to the task and removing it once it is done. In
connection.py, all ensure_future() produces a task.
This is done by adding them to a set and removing them when the task is done. asyncio itself only keeps a weak references to all tasks. A task can therefore be destroyed when it is not referenced anymore. When this happens, we get things like that:
This seldomly happens and I still have a hard time understanding the exact cause.
To workaround that, we provide a tiny wrapper around
ensure_future()
keeping a reference to the task and removing it once it is done. Inconnection.py
, allensure_future()
produces a task.