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

Reply via email to