1 |
commit: 90d78484d6be481a9caf22c017c62ea43f8ffe33 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 1 06:22:10 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 1 06:46:27 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=90d78484 |
7 |
|
8 |
_PortageEventLoop: add _asyncio_* properties for internal use |
9 |
|
10 |
It's better to avoid accessing the _PortageEventLoop._loop |
11 |
attribute which exposes *all* EventLoop methods, therefore expose |
12 |
_asyncio_child_watcher and _asyncio_wrapper attributes for use by |
13 |
portage internals, providing minimal compatibility between |
14 |
_PortageEventloop and EventLoop. |
15 |
|
16 |
pym/portage/dbapi/porttree.py | 2 +- |
17 |
.../util/futures/asyncio/test_subprocess_exec.py | 2 +- |
18 |
.../tests/util/futures/test_iter_completed.py | 2 +- |
19 |
pym/portage/util/futures/executor/fork.py | 2 +- |
20 |
pym/portage/util/futures/iter_completed.py | 2 +- |
21 |
pym/portage/util/futures/unix_events.py | 22 ++++++++++++++++++++++ |
22 |
6 files changed, 27 insertions(+), 5 deletions(-) |
23 |
|
24 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
25 |
index 3ce214cd7..6c38232bb 100644 |
26 |
--- a/pym/portage/dbapi/porttree.py |
27 |
+++ b/pym/portage/dbapi/porttree.py |
28 |
@@ -667,7 +667,7 @@ class portdbapi(dbapi): |
29 |
|
30 |
proc = EbuildMetadataPhase(cpv=mycpv, |
31 |
ebuild_hash=ebuild_hash, portdb=self, |
32 |
- repo_path=mylocation, scheduler=loop._loop, |
33 |
+ repo_path=mylocation, scheduler=loop, |
34 |
settings=self.doebuild_settings) |
35 |
|
36 |
proc.addExitListener(functools.partial(self._aux_get_return, |
37 |
|
38 |
diff --git a/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py b/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py |
39 |
index 8c8c395ca..be103a9e0 100644 |
40 |
--- a/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py |
41 |
+++ b/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py |
42 |
@@ -34,7 +34,7 @@ class _Reader(object): |
43 |
def __init__(self, future, input_file, loop): |
44 |
self._future = future |
45 |
self._pipe_reader = PipeReader( |
46 |
- input_files={'input_file':input_file}, scheduler=loop._loop) |
47 |
+ input_files={'input_file':input_file}, scheduler=loop) |
48 |
|
49 |
self._future.add_done_callback(self._cancel_callback) |
50 |
self._pipe_reader.addExitListener(self._eof) |
51 |
|
52 |
diff --git a/pym/portage/tests/util/futures/test_iter_completed.py b/pym/portage/tests/util/futures/test_iter_completed.py |
53 |
index 71343c22d..90668eb02 100644 |
54 |
--- a/pym/portage/tests/util/futures/test_iter_completed.py |
55 |
+++ b/pym/portage/tests/util/futures/test_iter_completed.py |
56 |
@@ -46,7 +46,7 @@ class IterCompletedTestCase(TestCase): |
57 |
def future_generator(): |
58 |
for task in tasks: |
59 |
task.future = loop.create_future() |
60 |
- task.scheduler = loop._loop |
61 |
+ task.scheduler = loop |
62 |
task.start() |
63 |
yield task.future |
64 |
|
65 |
|
66 |
diff --git a/pym/portage/util/futures/executor/fork.py b/pym/portage/util/futures/executor/fork.py |
67 |
index 51367f934..81c292e2c 100644 |
68 |
--- a/pym/portage/util/futures/executor/fork.py |
69 |
+++ b/pym/portage/util/futures/executor/fork.py |
70 |
@@ -54,7 +54,7 @@ class ForkExecutor(object): |
71 |
future, proc = self._submit_queue.popleft() |
72 |
future.add_done_callback(functools.partial(self._cancel_cb, proc)) |
73 |
proc.addExitListener(functools.partial(self._proc_exit, future)) |
74 |
- proc.scheduler = self._loop._loop |
75 |
+ proc.scheduler = self._loop |
76 |
proc.start() |
77 |
self._running_tasks[id(proc)] = proc |
78 |
|
79 |
|
80 |
diff --git a/pym/portage/util/futures/iter_completed.py b/pym/portage/util/futures/iter_completed.py |
81 |
index 1d6a9a4bd..8b0f417d9 100644 |
82 |
--- a/pym/portage/util/futures/iter_completed.py |
83 |
+++ b/pym/portage/util/futures/iter_completed.py |
84 |
@@ -77,7 +77,7 @@ def async_iter_completed(futures, max_jobs=None, max_load=None, loop=None): |
85 |
task_generator(), |
86 |
max_jobs=max_jobs, |
87 |
max_load=max_load, |
88 |
- event_loop=loop._loop) |
89 |
+ event_loop=loop) |
90 |
|
91 |
def done_callback(future_done_set, wait_result): |
92 |
"""Propagate results from wait_result to future_done_set.""" |
93 |
|
94 |
diff --git a/pym/portage/util/futures/unix_events.py b/pym/portage/util/futures/unix_events.py |
95 |
index 1a86ed439..00f522b61 100644 |
96 |
--- a/pym/portage/util/futures/unix_events.py |
97 |
+++ b/pym/portage/util/futures/unix_events.py |
98 |
@@ -72,6 +72,28 @@ class _PortageEventLoop(events.AbstractEventLoop): |
99 |
self.set_debug = loop.set_debug |
100 |
self.get_debug = loop.get_debug |
101 |
|
102 |
+ @property |
103 |
+ def _asyncio_child_watcher(self): |
104 |
+ """ |
105 |
+ In order to avoid accessing the internal _loop attribute, portage |
106 |
+ internals should use this property when possible. |
107 |
+ |
108 |
+ @rtype: asyncio.AbstractChildWatcher |
109 |
+ @return: the internal event loop's AbstractChildWatcher interface |
110 |
+ """ |
111 |
+ return self._loop._asyncio_child_watcher |
112 |
+ |
113 |
+ @property |
114 |
+ def _asyncio_wrapper(self): |
115 |
+ """ |
116 |
+ In order to avoid accessing the internal _loop attribute, portage |
117 |
+ internals should use this property when possible. |
118 |
+ |
119 |
+ @rtype: asyncio.AbstractEventLoop |
120 |
+ @return: the internal event loop's AbstractEventLoop interface |
121 |
+ """ |
122 |
+ return self |
123 |
+ |
124 |
def create_task(self, coro): |
125 |
""" |
126 |
Schedule a coroutine object. |