[issue37202] Future.cancelled is not set to true immediately after calling Future.cancel

Andrew Svetlov report at bugs.python.org
Sat Jun 8 09:21:37 EDT 2019


Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:

This is the expected behavior.

asyncio.ensure_future() returns not a future but a task for your case.
Task cancellation requires at least one context switch to finish the task.

P.S.
I suggest replacing `asyncio.ensure_future()` with `asyncio.create_task()` to avoid confusion.

----------

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


More information about the Python-bugs-list mailing list