[New-bugs-announce] [issue24578] [RFE] Add asyncio.wait_for_result API

Sven R. Kunze report at bugs.python.org
Mon Jul 6 20:01:54 CEST 2015


New submission from Sven R. Kunze:

In order to complement http://bugs.python.org/issue24571, this is another high-level convenience API for asyncio to treat an awaitable like a usual subroutine (credits go to Nick Coghlan):

    # Call awaitable from synchronous code
    def wait_for_result(awaitable):
        """Usage: result = asyncio.wait_for_result(awaitable)"""
        return asyncio.get_event_loop().run_until_complete(awaitable.__await__())

It may not be that conceptually dense, however, I feel for projects transitioning from the classical subroutine world to the asyncio world, this functionality might prove useful to bridge both worlds seamlessly when necessary.

----------
components: asyncio
messages: 246373
nosy: gvanrossum, haypo, srkunze, yselivanov
priority: normal
severity: normal
status: open
title: [RFE] Add asyncio.wait_for_result API
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24578>
_______________________________________


More information about the New-bugs-announce mailing list