[issue32363] Deprecate task.set_result() and task.set_exception()

Chris Jerdonek report at bugs.python.org
Tue Feb 19 14:17:56 EST 2019


Chris Jerdonek <chris.jerdonek at gmail.com> added the comment:

A second reason why Task.cancel() seems to be an incomplete replacement:

Task.set_exception() and Task.set_result() both give you a way to unconditionally end a task. With cancel() though, the docs say, "Task.cancel() does not guarantee that the Task will be cancelled." [1]

The reason you might want to unconditionally end a task is if e.g. you already called Task.cancel() and it is still running after waiting a certain amount of time.

[1]: https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32363>
_______________________________________


More information about the Python-bugs-list mailing list