This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: No explanation of how a task gets destroyed in asyncio 'task' documentation
Type: behavior Stage: resolved
Components: asyncio, Documentation Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: cheryl.sabella, docs@python, giampaolo.rodola, gvanrossum, martin.panter, pitrou, r.david.murray, vstinner, yselivanov
Priority: normal Keywords:

Created on 2014-09-24 00:02 by r.david.murray, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg227400 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-09-24 00:02
In https://docs.python.org/3/library/asyncio-task.html#task, there is a note about a warning being logged if a pending task is destroyed.  The section does not explain or link to an explanation of how a task might get destroyed.  Nor does it define pending, but that seems reasonably clear from context (ie: the future has not completed).

The example linked to does not show how the pending task got destroyed, it only shows an example of the resulting logging, with not enough information to really understand what the final line of the error message is reporting (is kill_me an asyncio API, or the name of the task, or the future it is wrapping?)
msg227454 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-09-24 14:34
"destroyed" means "collected by the garbage collector", when the last reference the task objected was cleared. To be honest, I have no idea who keeps a reference to tasks nor how the "pending task destroyed" bug occurs.

"pending" means that the execution of the coroutine object didn't finish. In fact, it's related to Task.done(): a task is pending is task.done() is False.

There is a corner case: if task.cancel() was called but the coroutine object was not executed yet to handle the CancelledError, the task is still "pending".

Maybe "pending" is not the best word, and "not done" is better.
msg334992 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-02-07 00:39
It seems that the note about a warning being logged if a pending task is destroyed does not exist in the new, rewritten version of the asyncio docs.  Therefore, I'm going to close this as out of date.
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66664
2019-02-07 00:39:24cheryl.sabellasetstatus: open -> closed

nosy: + cheryl.sabella
messages: + msg334992

resolution: out of date
stage: resolved
2014-09-26 04:06:45martin.pantersetnosy: + martin.panter
2014-09-24 14:34:24vstinnersetmessages: + msg227454
2014-09-24 14:28:20vstinnersetcomponents: + asyncio
2014-09-24 08:50:50pitrousetnosy: + gvanrossum, pitrou, vstinner, giampaolo.rodola, yselivanov
2014-09-24 00:02:23r.david.murraycreate