Message246373
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. |
|
Date |
User |
Action |
Args |
2015-07-06 18:01:54 | srkunze | set | recipients:
+ srkunze, gvanrossum, vstinner, yselivanov |
2015-07-06 18:01:54 | srkunze | set | messageid: <1436205714.01.0.481233835807.issue24578@psf.upfronthosting.co.za> |
2015-07-06 18:01:53 | srkunze | link | issue24578 messages |
2015-07-06 18:01:53 | srkunze | create | |
|