commit:     a1360e017b7ee8156ad4ad850e2f8ea40228ca1a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May  7 00:06:07 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May  7 00:19:54 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a1360e01

EventLoop.run_in_executor: use asyncio.wrap_future

Since executors from the concurrent.futures package return
concurrent.futures.Future, it's necessary to wrap them.

 pym/portage/util/_eventloop/EventLoop.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/pym/portage/util/_eventloop/EventLoop.py 
b/pym/portage/util/_eventloop/EventLoop.py
index fc7380b03..de0795224 100644
--- a/pym/portage/util/_eventloop/EventLoop.py
+++ b/pym/portage/util/_eventloop/EventLoop.py
@@ -13,6 +13,11 @@ import signal
 import sys
 import traceback
 
+try:
+       import asyncio as _real_asyncio
+except ImportError:
+       _real_asyncio = None
+
 try:
        import fcntl
 except ImportError:
@@ -937,7 +942,11 @@ class EventLoop(object):
                        if executor is None:
                                executor = ForkExecutor(loop=self)
                                self._default_executor = executor
-               return executor.submit(func, *args)
+               future = executor.submit(func, *args)
+               if _real_asyncio is not None:
+                       future = _real_asyncio.wrap_future(future,
+                               loop=self._asyncio_wrapper)
+               return future
 
        def is_running(self):
                """Return whether the event loop is currently running."""

Reply via email to