diff -r c2c3b79ba992 Lib/concurrent/futures/_base.py --- a/Lib/concurrent/futures/_base.py Thu Jun 04 11:10:36 2015 -0400 +++ b/Lib/concurrent/futures/_base.py Thu Jun 04 11:36:55 2015 -0400 @@ -506,6 +506,26 @@ self._condition.notify_all() self._invoke_callbacks() + def __await__(self): + import asyncio + + def callback(fut, afut): + # This function will be called from asyncio loop thread + try: + result = fut.result() + except Exception as ex: + afut.set_exception(ex) + else: + afut.set_result(result) + + loop = asyncio.get_event_loop() + afut = asyncio.Future(loop=loop) + self.add_done_callback( + lambda fut: loop.call_soon_threadsafe(callback, fut, afut)) + + return iter(afut) + + class Executor(object): """This is an abstract base class for concrete asynchronous executors.""" diff -r c2c3b79ba992 Lib/test/test_asyncio/test_pep492.py --- a/Lib/test/test_asyncio/test_pep492.py Thu Jun 04 11:10:36 2015 -0400 +++ b/Lib/test/test_asyncio/test_pep492.py Thu Jun 04 11:36:55 2015 -0400 @@ -134,5 +134,30 @@ data = self.loop.run_until_complete(foo()) self.assertEqual(data, 'spam') + +class ConcurrentFuturesIntegrationTests(BaseTest): + + def test_concurrent_futures_1(self): + import time + from concurrent import futures as cf + + executor = cf.ThreadPoolExecutor() + def waiter(): + time.sleep(0.01) + return 'spam' + + async def coro(): + return await executor.submit(waiter) + + self.loop._write_to_self = mock.Mock() + + asyncio.set_event_loop(self.loop) + try: + data = self.loop.run_until_complete(coro()) + self.assertEqual(data, 'spam') + finally: + asyncio.set_event_loop(None) + + if __name__ == '__main__': unittest.main()