This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gordon
Recipients gordon, gvanrossum, vstinner, yselivanov
Date 2016-03-13.11:46:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1457869570.39.0.866858008064.issue26552@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-03-13 11:46:10gordonsetrecipients: + gordon, gvanrossum, vstinner, yselivanov
2016-03-13 11:46:10gordonsetmessageid: <1457869570.39.0.866858008064.issue26552@psf.upfronthosting.co.za>
2016-03-13 11:46:10gordonlinkissue26552 messages
2016-03-13 11:46:10gordoncreate