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.

Author yselivanov
Recipients Ilya.Kulakov, asvetlov, chris.jerdonek, yselivanov
Date 2019-02-19.19:14:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550603654.47.0.265700364416.issue32363@roundup.psfhosted.org>
In-reply-to
Content
> One reason why Task.cancel() is an incomplete replacement for Task.set_exception() is that you don't have an easy way to communicate why the task was ended.


The result of the Task is bound to the result of the coroutine it wraps.  If the coroutine raises an exception -- that's the exception of the Task object.  If the coroutine returns a value -- that's the result value of the Task object.  If the coroutine is cancelled via the "Task.cancel()" call -- asyncio.CancelledError is likely the result of the Task.

Key rule: the wrapped coroutine dictates the result of the Task, not the other way around.  The Task can signal cancellation, but even then, the final result is up to the coroutine.

There's no clear reason to complicate the Task<->coroutine relationship by allowing to inject arbitrary exceptions into running coroutines.
History
Date User Action Args
2019-02-19 19:14:14yselivanovsetrecipients: + yselivanov, asvetlov, chris.jerdonek, Ilya.Kulakov
2019-02-19 19:14:14yselivanovsetmessageid: <1550603654.47.0.265700364416.issue32363@roundup.psfhosted.org>
2019-02-19 19:14:14yselivanovlinkissue32363 messages
2019-02-19 19:14:14yselivanovcreate