[New-bugs-announce] [issue26552] Failing ensure_future still creates a Task
Damien Nicolas
report at bugs.python.org
Sun Mar 13 07:46:10 EDT 2016
New submission from Damien Nicolas:
When calling asyncio.ensure_future() on a coroutine, and if the loop is closed, ensure_future() will raise a RuntimeError.
However, it still creates a Task, which will generate a RuntimeWarning that we can’t fix since there is no way to cancel the Task.
Here is the code to reproduce the bug:
import asyncio
l = asyncio.get_event_loop()
l.close()
async def foo():
pass
try:
# Since the exception raises here, fut is never set
# so we can't call fut.cancel()
fut = asyncio.ensure_future(foo())
except RuntimeError:
pass
# stderr:
# aio.py:12: RuntimeWarning: coroutine 'foo' was never awaited
# pass
----------
components: asyncio
messages: 261696
nosy: gordon, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: Failing ensure_future still creates a Task
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26552>
_______________________________________
More information about the New-bugs-announce
mailing list