[issue30048] If a task is canceled at the right moment, the cancellation is ignored
Evgeny Kapun
report at bugs.python.org
Tue Apr 11 20:11:24 EDT 2017
New submission from Evgeny Kapun:
If I run this code:
import asyncio as a
@a.coroutine
def coro1():
yield from a.ensure_future(coro2())
print("Still here")
yield from a.sleep(1)
print("Still here 2")
@a.coroutine
def coro2():
yield from a.sleep(1)
res = task.cancel()
print("Canceled task:", res)
loop = a.get_event_loop()
task = a.ensure_future(coro1())
loop.run_until_complete(task)
I expect the task to stop shortly after a call to cancel(). It should surely stop when I try to sleep(). But it doesn't. On my machine this prints:
Canceled task: True
Still here
Still here 2
So, cancel() returns True, but the task doesn't seem to be canceled.
----------
components: asyncio
messages: 291522
nosy: abacabadabacaba, yselivanov
priority: normal
severity: normal
status: open
title: If a task is canceled at the right moment, the cancellation is ignored
type: behavior
versions: Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30048>
_______________________________________
More information about the Python-bugs-list
mailing list