aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2018-04-30 23:22:10 -0700
committerZac Medico <zmedico@gentoo.org>2018-04-30 23:46:27 -0700
commit90d78484d6be481a9caf22c017c62ea43f8ffe33 (patch)
treea8fcd099c9d64ecee326b9db8660eedc9240c4aa
parentAbstractPollTask: change timeout units to seconds (diff)
downloadportage-90d78484.tar.gz
portage-90d78484.tar.bz2
portage-90d78484.zip
_PortageEventLoop: add _asyncio_* properties for internal use
It's better to avoid accessing the _PortageEventLoop._loop attribute which exposes *all* EventLoop methods, therefore expose _asyncio_child_watcher and _asyncio_wrapper attributes for use by portage internals, providing minimal compatibility between _PortageEventloop and EventLoop.
-rw-r--r--pym/portage/dbapi/porttree.py2
-rw-r--r--pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py2
-rw-r--r--pym/portage/tests/util/futures/test_iter_completed.py2
-rw-r--r--pym/portage/util/futures/executor/fork.py2
-rw-r--r--pym/portage/util/futures/iter_completed.py2
-rw-r--r--pym/portage/util/futures/unix_events.py22
6 files changed, 27 insertions, 5 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 3ce214cd7..6c38232bb 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -667,7 +667,7 @@ class portdbapi(dbapi):
proc = EbuildMetadataPhase(cpv=mycpv,
ebuild_hash=ebuild_hash, portdb=self,
- repo_path=mylocation, scheduler=loop._loop,
+ repo_path=mylocation, scheduler=loop,
settings=self.doebuild_settings)
proc.addExitListener(functools.partial(self._aux_get_return,
diff --git a/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py b/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py
index 8c8c395ca..be103a9e0 100644
--- a/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py
+++ b/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py
@@ -34,7 +34,7 @@ class _Reader(object):
def __init__(self, future, input_file, loop):
self._future = future
self._pipe_reader = PipeReader(
- input_files={'input_file':input_file}, scheduler=loop._loop)
+ input_files={'input_file':input_file}, scheduler=loop)
self._future.add_done_callback(self._cancel_callback)
self._pipe_reader.addExitListener(self._eof)
diff --git a/pym/portage/tests/util/futures/test_iter_completed.py b/pym/portage/tests/util/futures/test_iter_completed.py
index 71343c22d..90668eb02 100644
--- a/pym/portage/tests/util/futures/test_iter_completed.py
+++ b/pym/portage/tests/util/futures/test_iter_completed.py
@@ -46,7 +46,7 @@ class IterCompletedTestCase(TestCase):
def future_generator():
for task in tasks:
task.future = loop.create_future()
- task.scheduler = loop._loop
+ task.scheduler = loop
task.start()
yield task.future
diff --git a/pym/portage/util/futures/executor/fork.py b/pym/portage/util/futures/executor/fork.py
index 51367f934..81c292e2c 100644
--- a/pym/portage/util/futures/executor/fork.py
+++ b/pym/portage/util/futures/executor/fork.py
@@ -54,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._loop
+ proc.scheduler = self._loop
proc.start()
self._running_tasks[id(proc)] = proc
diff --git a/pym/portage/util/futures/iter_completed.py b/pym/portage/util/futures/iter_completed.py
index 1d6a9a4bd..8b0f417d9 100644
--- a/pym/portage/util/futures/iter_completed.py
+++ b/pym/portage/util/futures/iter_completed.py
@@ -77,7 +77,7 @@ def async_iter_completed(futures, max_jobs=None, max_load=None, loop=None):
task_generator(),
max_jobs=max_jobs,
max_load=max_load,
- event_loop=loop._loop)
+ event_loop=loop)
def done_callback(future_done_set, wait_result):
"""Propagate results from wait_result to future_done_set."""
diff --git a/pym/portage/util/futures/unix_events.py b/pym/portage/util/futures/unix_events.py
index 1a86ed439..00f522b61 100644
--- a/pym/portage/util/futures/unix_events.py
+++ b/pym/portage/util/futures/unix_events.py
@@ -72,6 +72,28 @@ class _PortageEventLoop(events.AbstractEventLoop):
self.set_debug = loop.set_debug
self.get_debug = loop.get_debug
+ @property
+ def _asyncio_child_watcher(self):
+ """
+ In order to avoid accessing the internal _loop attribute, portage
+ internals should use this property when possible.
+
+ @rtype: asyncio.AbstractChildWatcher
+ @return: the internal event loop's AbstractChildWatcher interface
+ """
+ return self._loop._asyncio_child_watcher
+
+ @property
+ def _asyncio_wrapper(self):
+ """
+ In order to avoid accessing the internal _loop attribute, portage
+ internals should use this property when possible.
+
+ @rtype: asyncio.AbstractEventLoop
+ @return: the internal event loop's AbstractEventLoop interface
+ """
+ return self
+
def create_task(self, coro):
"""
Schedule a coroutine object.