Issue 22474: No explanation of how a task gets destroyed in asyncio 'task' documentation (original) (raw)

Issue22474

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:08 admin set github: 66664
2019-02-07 00:39:24 cheryl.sabella set status: open -> closednosy: + cheryl.sabellamessages: + resolution: out of datestage: resolved
2014-09-26 04:06:45 martin.panter set nosy: + martin.panter
2014-09-24 14:34:24 vstinner set messages: +
2014-09-24 14:28:20 vstinner set components: + asyncio
2014-09-24 08:50:50 pitrou set nosy: + gvanrossum, pitrou, vstinner, giampaolo.rodola, yselivanov
2014-09-24 00:02:23 r.david.murray create