[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-07 Thread Nick Coghlan
Nick Coghlan added the comment: As Guido suggested, merging back into issue 24571 -- resolution: -> duplicate status: open -> closed superseder: -> [RFE] Add asyncio.call_async API ___ Python tracker

[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-07 Thread Guido van Rossum
Guido van Rossum added the comment: Maybe the two issues should be merged so the two proposals can be considered together. I'm -0 on both, because each of these is really just one line of code and it seems they both encourage mindless copy-pasting that just saddens me (similar to "Python" scri

[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-07 Thread Nick Coghlan
Nick Coghlan added the comment: It occurs to me that given both this API and the "call_async()" API now proposed in issue 24571, otherwise synchronous code can do things like: futureB = asyncio.call_async(slow_io_bound_operation) futureC = asyncio.call_async(another_slow_io_bound_operat

[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-06 Thread Martin Panter
Martin Panter added the comment: I don’t think you need the __await__() call. Just do loop.run_until_complete(awaitable). I understand “asyncio” doesn’t support recursive calls into the same event loop on purpose; see Issue 22239. So this code would only be useful from outside of the event lo

[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-06 Thread Sven R. Kunze
Changes by Sven R. Kunze : -- nosy: +srkunze ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-06 Thread Sven R. Kunze
Changes by Sven R. Kunze : -- nosy: +giampaolo.rodola, ncoghlan, pitrou -srkunze type: -> enhancement ___ Python tracker ___ ___ Pyth

[issue24578] [RFE] Add asyncio.wait_for_result API

2015-07-06 Thread Sven R. Kunze
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(awa