[issue32363] Deprecate task.set_result() and task.set_exception()
Andrew Svetlov
report at bugs.python.org
Tue Feb 19 15:22:58 EST 2019
Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:
I agree with Yuri.
`Task.set_exception()` (let's assume it works) is very dangerous: if cancellation exception doesn't bubble up from coroutine code there is a very high chance to get broken invariants and not-released resources.
The same situation is possible with classic threads: killing a thread without unwinding a call stack leads to locked mutexes etc.
Regarding distinguishing explicit cancellation from timeout exhausting: it can be done with current asyncio design by using a flag. Take a look on async_timeout context manager, __aexit__() implementation: https://github.com/aio-libs/async-timeout/blob/master/async_timeout/__init__.py#L88-L97
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32363>
_______________________________________
More information about the Python-bugs-list
mailing list