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 <rep...@bugs.python.org>
<http://bugs.python.org/issue26552>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to