[issue30048] If a task is canceled at the right moment, the cancellation is ignored

INADA Naoki report at bugs.python.org
Wed Apr 12 04:46:32 EDT 2017


INADA Naoki added the comment:

This behavior is documented as:

https://docs.python.org/3.6/library/asyncio-task.html#asyncio.Task.cancel

> Unlike Future.cancel(), this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception.
>
> Immediately after this method is called, cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called).

I agree that this behavior is somewhat surprising.
But I don't know how can I fix the behavior.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30048>
_______________________________________


More information about the Python-bugs-list mailing list