commit:     52d4689740f5f9fcf1cf7423e3fe4089dbb4c718
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 11 02:01:43 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Apr 11 02:01:43 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=52d46897

ForkExecutor: support asyncio via _PortageEventLoopPolicy (bug 649588)

Support portage's internal EventLoop as well as the _PortageEventLoop
asyncio compatibility wrapper, by using the respective _loop and
_asyncio_wrapper attributes where appropriate.

Bug: https://bugs.gentoo.org/649588

 pym/portage/util/futures/executor/fork.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/portage/util/futures/executor/fork.py 
b/pym/portage/util/futures/executor/fork.py
index 496b4e892..919a72bfd 100644
--- a/pym/portage/util/futures/executor/fork.py
+++ b/pym/portage/util/futures/executor/fork.py
@@ -25,7 +25,8 @@ class ForkExecutor(object):
        """
        def __init__(self, max_workers=None, loop=None):
                self._max_workers = max_workers or multiprocessing.cpu_count()
-               self._loop = loop or global_event_loop()
+               loop = loop or global_event_loop()
+               self._loop = getattr(loop, '_asyncio_wrapper', loop)
                self._submit_queue = collections.deque()
                self._running_tasks = {}
                self._shutdown = False
@@ -53,7 +54,7 @@ class ForkExecutor(object):
                        future, proc = self._submit_queue.popleft()
                        
future.add_done_callback(functools.partial(self._cancel_cb, proc))
                        proc.addExitListener(functools.partial(self._proc_exit, 
future))
-                       proc.scheduler = self._loop
+                       proc.scheduler = self._loop._loop
                        proc.start()
                        self._running_tasks[id(proc)] = proc
 

Reply via email to