diff --git a/asyncio/base_events.py b/asyncio/base_events.py index 4505732f..d1d9564f 100644 --- a/asyncio/base_events.py +++ b/asyncio/base_events.py @@ -521,6 +521,7 @@ def call_soon_threadsafe(self, callback, *args): self._write_to_self() return handle + @coroutine def run_in_executor(self, executor, func, *args): if (coroutines.iscoroutine(func) or coroutines.iscoroutinefunction(func)): @@ -539,7 +540,7 @@ def run_in_executor(self, executor, func, *args): if executor is None: executor = concurrent.futures.ThreadPoolExecutor(_MAX_WORKERS) self._default_executor = executor - return futures.wrap_future(executor.submit(func, *args), loop=self) + return (yield from futures.wrap_future(executor.submit(func, *args), loop=self)) def set_default_executor(self, executor): self._default_executor = executor diff --git a/tests/test_events.py b/tests/test_events.py index f1746043..e99889d3 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -347,6 +347,7 @@ def run(arg): res, thread_id = self.loop.run_until_complete(f2) self.assertEqual(res, 'yo') self.assertNotEqual(thread_id, threading.get_ident()) + self.assertTrue(asyncio.iscoroutine(f2)) def test_reader_callback(self): r, w = test_utils.socketpair()