commit: 9ebbe247f9c92bc042a67d24cadb314f4f0a5319
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 16 06:13:09 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 16 06:17:52 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9ebbe247
Eventloop.run_until_complete: call asyncio.ensure_future
This eliminates the need for _PortageEventLoop to override the
Eventloop.run_until_complete method.
pym/portage/util/_eventloop/EventLoop.py | 2 ++
pym/portage/util/futures/unix_events.py | 15 +--------------
2 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/pym/portage/util/_eventloop/EventLoop.py
b/pym/portage/util/_eventloop/EventLoop.py
index 35d0a35ba..0024d162c 100644
--- a/pym/portage/util/_eventloop/EventLoop.py
+++ b/pym/portage/util/_eventloop/EventLoop.py
@@ -25,6 +25,7 @@ except ImportError:
import portage
portage.proxy.lazyimport.lazyimport(globals(),
+ 'portage.util.futures:asyncio',
'portage.util.futures.futures:Future',
'portage.util.futures.executor.fork:ForkExecutor',
'portage.util.futures.unix_events:_PortageEventLoop,_PortageChildWatcher',
@@ -781,6 +782,7 @@ class EventLoop(object):
@return: the Future's result
@raise: the Future's exception
"""
+ future = asyncio.ensure_future(future,
loop=self._asyncio_wrapper)
while not future.done():
self.iteration()
diff --git a/pym/portage/util/futures/unix_events.py
b/pym/portage/util/futures/unix_events.py
index 9d84ab6aa..d69b13718 100644
--- a/pym/portage/util/futures/unix_events.py
+++ b/pym/portage/util/futures/unix_events.py
@@ -30,7 +30,6 @@ from portage.util.futures import (
asyncio,
events,
)
-from portage.util.futures.futures import Future
class _PortageEventLoop(events.AbstractEventLoop):
@@ -45,6 +44,7 @@ class _PortageEventLoop(events.AbstractEventLoop):
@param loop: an instance of portage's internal event loop
"""
self._loop = loop
+ self.run_until_complete = loop.run_until_complete
self.call_soon = loop.call_soon
self.call_soon_threadsafe = loop.call_soon_threadsafe
self.call_later = loop.call_later
@@ -64,19 +64,6 @@ class _PortageEventLoop(events.AbstractEventLoop):
self.set_debug = loop.set_debug
self.get_debug = loop.get_debug
- def run_until_complete(self, future):
- """
- Run the event loop until a Future is done.
-
- @type future: asyncio.Future
- @param future: a Future to wait for
- @rtype: object
- @return: the Future's result
- @raise: the Future's exception
- """
- return self._loop.run_until_complete(
- asyncio.ensure_future(future, loop=self))
-
def create_task(self, coro):
"""
Schedule a coroutine object.