Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_async/, pym/_emerge/, pym/portage/_emirrordist/
Date: Sun, 29 Apr 2018 04:38:24
Message-Id: 1524976305.f01f504fc8d4ea7442379482889b1cee4be0fcf4.zmedico@gentoo
1 commit: f01f504fc8d4ea7442379482889b1cee4be0fcf4
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sun Apr 29 01:28:42 2018 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sun Apr 29 04:31:45 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f01f504f
7
8 AsynchronousTask: remove unused _wait() methods (bug 653856)
9
10 Remove _wait() and _waitpid_loop() methods which are unused since
11 AsynchronousTask.wait() now uses run_until_complete(self.async_wait())
12 instead. Also remove the iteration method from SchedulerInterface,
13 since there are no more consumers.
14
15 Bug: https://bugs.gentoo.org/653856
16
17 pym/_emerge/AbstractEbuildProcess.py | 27 ------------
18 pym/_emerge/AbstractPollTask.py | 8 +---
19 pym/_emerge/AsynchronousLock.py | 9 ----
20 pym/_emerge/AsynchronousTask.py | 6 ---
21 pym/_emerge/CompositeTask.py | 48 +--------------------
22 pym/_emerge/FifoIpcDaemon.py | 13 +-----
23 pym/_emerge/PipeReader.py | 7 ----
24 pym/_emerge/SpawnProcess.py | 12 +-----
25 pym/_emerge/SubProcess.py | 56 +------------------------
26 pym/portage/_emirrordist/MirrorDistTask.py | 7 ----
27 pym/portage/util/_async/AsyncScheduler.py | 25 +----------
28 pym/portage/util/_async/AsyncTaskFuture.py | 8 ----
29 pym/portage/util/_async/PipeLogger.py | 7 ----
30 pym/portage/util/_async/PipeReaderBlockingIO.py | 10 -----
31 pym/portage/util/_async/SchedulerInterface.py | 1 -
32 15 files changed, 6 insertions(+), 238 deletions(-)
33
34 diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py
35 index b10aa4bfa..03c834912 100644
36 --- a/pym/_emerge/AbstractEbuildProcess.py
37 +++ b/pym/_emerge/AbstractEbuildProcess.py
38 @@ -386,33 +386,6 @@ class AbstractEbuildProcess(SpawnProcess):
39 if not self.cancelled:
40 self._unexpected_exit()
41
42 - def _wait(self):
43 - """
44 - Override _wait to unlock self._build_dir if necessary. Normally, it
45 - should already be unlocked, so this functions only as a failsafe.
46 - Execution of the failsafe code will automatically become a fatal
47 - error at the same time as event loop recursion is disabled.
48 - """
49 - # SpawnProcess._wait() requires the pid, so wait here for the
50 - # pid to become available.
51 - while self._start_future is not None:
52 - self.scheduler.run_until_complete(self._start_future)
53 -
54 - SpawnProcess._wait(self)
55 -
56 - if self._build_dir is not None:
57 - self._build_dir_unlock = self._build_dir.async_unlock()
58 - # Unlock only once.
59 - self._build_dir = None
60 -
61 - if not (self._build_dir_unlock is None or
62 - self._build_dir_unlock.done()):
63 - # This will automatically become a fatal error at the same
64 - # time as event loop recursion is disabled.
65 - self.scheduler.run_until_complete(self._build_dir_unlock)
66 -
67 - return self.returncode
68 -
69 def _async_wait(self):
70 """
71 Override _async_wait to asynchronously unlock self._build_dir
72
73 diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
74 index 0aac97be5..0ce3594b4 100644
75 --- a/pym/_emerge/AbstractPollTask.py
76 +++ b/pym/_emerge/AbstractPollTask.py
77 @@ -1,4 +1,4 @@
78 -# Copyright 1999-2015 Gentoo Foundation
79 +# Copyright 1999-2018 Gentoo Foundation
80 # Distributed under the terms of the GNU General Public License v2
81
82 import array
83 @@ -136,12 +136,6 @@ class AbstractPollTask(AsynchronousTask):
84 self.returncode = self.returncode or os.EX_OK
85 self._async_wait()
86
87 - def _wait(self):
88 - if self.returncode is not None:
89 - return self.returncode
90 - self._wait_loop()
91 - return self.returncode
92 -
93 def _wait_loop(self, timeout=None):
94 loop = getattr(self.scheduler, '_asyncio_wrapper', self.scheduler)
95 tasks = [self.async_wait()]
96
97 diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py
98 index 2019adaab..c5991bcff 100644
99 --- a/pym/_emerge/AsynchronousLock.py
100 +++ b/pym/_emerge/AsynchronousLock.py
101 @@ -82,15 +82,6 @@ class AsynchronousLock(AsynchronousTask):
102 self._imp.poll()
103 return self.returncode
104
105 - def _wait(self):
106 - """
107 - Deprecated. Use _async_wait() instead.
108 - """
109 - if self.returncode is not None:
110 - return self.returncode
111 - self.returncode = self._imp.wait()
112 - return self.returncode
113 -
114 def async_unlock(self):
115 """
116 Release the lock asynchronously. Release notification is available
117
118 diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py
119 index 246895d71..cf6e6dc44 100644
120 --- a/pym/_emerge/AsynchronousTask.py
121 +++ b/pym/_emerge/AsynchronousTask.py
122 @@ -84,12 +84,6 @@ class AsynchronousTask(SlotObject):
123 self._wait_hook()
124 return self.returncode
125
126 - def _wait(self):
127 - """
128 - Deprecated. Use _async_wait() instead.
129 - """
130 - return self.returncode
131 -
132 def _async_wait(self):
133 """
134 For cases where _start exits synchronously, this method is a
135
136 diff --git a/pym/_emerge/CompositeTask.py b/pym/_emerge/CompositeTask.py
137 index 113e5935f..4662f0cf5 100644
138 --- a/pym/_emerge/CompositeTask.py
139 +++ b/pym/_emerge/CompositeTask.py
140 @@ -1,4 +1,4 @@
141 -# Copyright 1999-2012 Gentoo Foundation
142 +# Copyright 1999-2018 Gentoo Foundation
143 # Distributed under the terms of the GNU General Public License v2
144
145 from _emerge.AsynchronousTask import AsynchronousTask
146 @@ -47,52 +47,6 @@ class CompositeTask(AsynchronousTask):
147
148 return self.returncode
149
150 - def _wait(self):
151 -
152 - prev = None
153 - while True:
154 - task = self._current_task
155 - if task is None:
156 - # don't wait for the same task more than once
157 - break
158 - if task is self._TASK_QUEUED:
159 - if self.cancelled:
160 - self.returncode = 1
161 - self._current_task = None
162 - break
163 - else:
164 - while not self._task_queued_wait():
165 - self.scheduler.iteration()
166 - if self.returncode is not None:
167 - break
168 - elif self.cancelled:
169 - self.returncode = 1
170 - self._current_task = None
171 - break
172 - else:
173 - # try this again with new _current_task value
174 - continue
175 - if task is prev:
176 - if self.returncode is not None:
177 - # This is expected if we're being
178 - # called from the task's exit listener
179 - # after it's been cancelled.
180 - break
181 - # Before the task.wait() method returned, an exit
182 - # listener should have set self._current_task to either
183 - # a different task or None. Something is wrong.
184 - raise AssertionError("self._current_task has not " + \
185 - "changed since calling wait", self, task)
186 -
187 - # This triggers less recursion than calling task.wait().
188 - waiter = self.scheduler.create_future()
189 - task.addExitListener(waiter.set_result)
190 - while not waiter.done():
191 - self.scheduler.iteration()
192 - prev = task
193 -
194 - return self.returncode
195 -
196 def _assert_current(self, task):
197 """
198 Raises an AssertionError if the given task is not the
199
200 diff --git a/pym/_emerge/FifoIpcDaemon.py b/pym/_emerge/FifoIpcDaemon.py
201 index 6efdc11b4..3676e98da 100644
202 --- a/pym/_emerge/FifoIpcDaemon.py
203 +++ b/pym/_emerge/FifoIpcDaemon.py
204 @@ -1,4 +1,4 @@
205 -# Copyright 2010-2013 Gentoo Foundation
206 +# Copyright 2010-2018 Gentoo Foundation
207 # Distributed under the terms of the GNU General Public License v2
208
209 import sys
210 @@ -81,17 +81,6 @@ class FifoIpcDaemon(AbstractPollTask):
211 # notify exit listeners
212 self._async_wait()
213
214 - def _wait(self):
215 - """
216 - Deprecated. Use _async_wait() instead.
217 - """
218 - if self.returncode is not None:
219 - return self.returncode
220 - self._wait_loop()
221 - if self.returncode is None:
222 - self.returncode = os.EX_OK
223 - return self.returncode
224 -
225 def _input_handler(self, fd, event):
226 raise NotImplementedError(self)
227
228
229 diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
230 index eabf9f40b..267d0cea1 100644
231 --- a/pym/_emerge/PipeReader.py
232 +++ b/pym/_emerge/PipeReader.py
233 @@ -52,13 +52,6 @@ class PipeReader(AbstractPollTask):
234 if self.returncode is None:
235 self.returncode = self._cancelled_returncode
236
237 - def _wait(self):
238 - if self.returncode is not None:
239 - return self.returncode
240 - self._wait_loop()
241 - self.returncode = os.EX_OK
242 - return self.returncode
243 -
244 def getvalue(self):
245 """Retrieve the entire contents"""
246 return b''.join(self._read_data)
247
248 diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
249 index 7326254ca..78eb5e9c0 100644
250 --- a/pym/_emerge/SpawnProcess.py
251 +++ b/pym/_emerge/SpawnProcess.py
252 @@ -1,4 +1,4 @@
253 -# Copyright 2008-2013 Gentoo Foundation
254 +# Copyright 2008-2018 Gentoo Foundation
255 # Distributed under the terms of the GNU General Public License v2
256
257 try:
258 @@ -172,16 +172,6 @@ class SpawnProcess(SubProcess):
259 self._pipe_logger = None
260 self._async_waitpid()
261
262 - def _waitpid_loop(self):
263 - SubProcess._waitpid_loop(self)
264 -
265 - pipe_logger = self._pipe_logger
266 - if pipe_logger is not None:
267 - self._pipe_logger = None
268 - pipe_logger.removeExitListener(self._pipe_logger_exit)
269 - pipe_logger.cancel()
270 - pipe_logger.wait()
271 -
272 def _set_returncode(self, wait_retval):
273 SubProcess._set_returncode(self, wait_retval)
274 self._cgroup_cleanup()
275
276 diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py
277 index 13cf9d361..3939de3ed 100644
278 --- a/pym/_emerge/SubProcess.py
279 +++ b/pym/_emerge/SubProcess.py
280 @@ -1,4 +1,4 @@
281 -# Copyright 1999-2013 Gentoo Foundation
282 +# Copyright 1999-2018 Gentoo Foundation
283 # Distributed under the terms of the GNU General Public License v2
284
285 import logging
286 @@ -61,48 +61,6 @@ class SubProcess(AbstractPollTask):
287 return self.pid is not None and \
288 self.returncode is None
289
290 - def _wait(self):
291 - """
292 - Deprecated. Use _async_wait() instead.
293 - """
294 - if self.returncode is not None:
295 - return self.returncode
296 -
297 - if self._registered:
298 - if self.cancelled:
299 - self._wait_loop(timeout=self._cancel_timeout)
300 - if self._registered:
301 - try:
302 - os.kill(self.pid, signal.SIGKILL)
303 - except OSError as e:
304 - if e.errno == errno.EPERM:
305 - # Reported with hardened kernel (bug #358211).
306 - writemsg_level(
307 - "!!! kill: (%i) - Operation not permitted\n" %
308 - (self.pid,), level=logging.ERROR,
309 - noiselevel=-1)
310 - elif e.errno != errno.ESRCH:
311 - raise
312 - del e
313 - self._wait_loop(timeout=self._cancel_timeout)
314 - if self._registered:
315 - self._orphan_process_warn()
316 - else:
317 - self._wait_loop()
318 -
319 - if self.returncode is not None:
320 - return self.returncode
321 -
322 - if not isinstance(self.pid, int):
323 - # Get debug info for bug #403697.
324 - raise AssertionError(
325 - "%s: pid is non-integer: %s" %
326 - (self.__class__.__name__, repr(self.pid)))
327 -
328 - self._waitpid_loop()
329 -
330 - return self.returncode
331 -
332 def _async_waitpid(self):
333 """
334 Wait for exit status of self.pid asynchronously, and then
335 @@ -122,18 +80,6 @@ class SubProcess(AbstractPollTask):
336 self._set_returncode((pid, condition))
337 self._async_wait()
338
339 - def _waitpid_loop(self):
340 - """
341 - Deprecated. Use _async_waitpid() instead.
342 - """
343 - source_id = self.scheduler.child_watch_add(
344 - self.pid, self._waitpid_cb)
345 - try:
346 - while self.returncode is None:
347 - self.scheduler.iteration()
348 - finally:
349 - self.scheduler.source_remove(source_id)
350 -
351 def _waitpid_cb(self, pid, condition, user_data=None):
352 if pid != self.pid:
353 raise AssertionError("expected pid %s, got %s" % (self.pid, pid))
354
355 diff --git a/pym/portage/_emirrordist/MirrorDistTask.py b/pym/portage/_emirrordist/MirrorDistTask.py
356 index b8cde0af4..8eb3081c6 100644
357 --- a/pym/portage/_emirrordist/MirrorDistTask.py
358 +++ b/pym/portage/_emirrordist/MirrorDistTask.py
359 @@ -241,13 +241,6 @@ class MirrorDistTask(CompositeTask):
360 else:
361 self._async_wait()
362
363 - def _wait(self):
364 - """
365 - Deprecated. Use _async_wait() instead.
366 - """
367 - CompositeTask._wait(self)
368 - self._cleanup()
369 -
370 def _async_wait(self):
371 """
372 Override _async_wait to call self._cleanup().
373
374 diff --git a/pym/portage/util/_async/AsyncScheduler.py b/pym/portage/util/_async/AsyncScheduler.py
375 index 2ddbaa885..90e803eba 100644
376 --- a/pym/portage/util/_async/AsyncScheduler.py
377 +++ b/pym/portage/util/_async/AsyncScheduler.py
378 @@ -1,4 +1,4 @@
379 -# Copyright 2012-2013 Gentoo Foundation
380 +# Copyright 2012-2018 Gentoo Foundation
381 # Distributed under the terms of the GNU General Public License v2
382
383 from portage import os
384 @@ -96,26 +96,3 @@ class AsyncScheduler(AsynchronousTask, PollScheduler):
385 """
386 self._cleanup()
387 super(AsyncScheduler, self)._async_wait()
388 -
389 - def _wait(self):
390 - """
391 - Deprecated. Use _async_wait() instead.
392 - """
393 - # Loop while there are jobs to be scheduled.
394 - while self._keep_scheduling():
395 - self._event_loop.iteration()
396 -
397 - # Clean shutdown of previously scheduled jobs. In the
398 - # case of termination, this allows for basic cleanup
399 - # such as flushing of buffered output to logs.
400 - while self._is_work_scheduled():
401 - self._event_loop.iteration()
402 -
403 - self._cleanup()
404 -
405 - if self._error_count > 0:
406 - self.returncode = 1
407 - else:
408 - self.returncode = os.EX_OK
409 -
410 - return self.returncode
411
412 diff --git a/pym/portage/util/_async/AsyncTaskFuture.py b/pym/portage/util/_async/AsyncTaskFuture.py
413 index cdc842b05..581f5ea66 100644
414 --- a/pym/portage/util/_async/AsyncTaskFuture.py
415 +++ b/pym/portage/util/_async/AsyncTaskFuture.py
416 @@ -29,11 +29,3 @@ class AsyncTaskFuture(AsynchronousTask):
417 else:
418 self.returncode = 1
419 self._async_wait()
420 -
421 - def _wait(self):
422 - """
423 - Deprecated. Use _async_wait() instead.
424 - """
425 - if self.returncode is None:
426 - self.scheduler.run_until_complete(self.future)
427 - return self.returncode
428
429 diff --git a/pym/portage/util/_async/PipeLogger.py b/pym/portage/util/_async/PipeLogger.py
430 index ed1202edf..02de74b16 100644
431 --- a/pym/portage/util/_async/PipeLogger.py
432 +++ b/pym/portage/util/_async/PipeLogger.py
433 @@ -66,13 +66,6 @@ class PipeLogger(AbstractPollTask):
434 if self.returncode is None:
435 self.returncode = self._cancelled_returncode
436
437 - def _wait(self):
438 - if self.returncode is not None:
439 - return self.returncode
440 - self._wait_loop()
441 - self.returncode = os.EX_OK
442 - return self.returncode
443 -
444 def _output_handler(self, fd, event):
445
446 background = self.background
447
448 diff --git a/pym/portage/util/_async/PipeReaderBlockingIO.py b/pym/portage/util/_async/PipeReaderBlockingIO.py
449 index 0727d2c6a..6933c9216 100644
450 --- a/pym/portage/util/_async/PipeReaderBlockingIO.py
451 +++ b/pym/portage/util/_async/PipeReaderBlockingIO.py
452 @@ -72,16 +72,6 @@ class PipeReaderBlockingIO(AbstractPollTask):
453 self.returncode = self._cancelled_returncode
454 self._async_wait()
455
456 - def _wait(self):
457 - """
458 - Deprecated. Use _async_wait() instead.
459 - """
460 - if self.returncode is not None:
461 - return self.returncode
462 - self._wait_loop()
463 - self.returncode = os.EX_OK
464 - return self.returncode
465 -
466 def getvalue(self):
467 """Retrieve the entire contents"""
468 with self._thread_rlock:
469
470 diff --git a/pym/portage/util/_async/SchedulerInterface.py b/pym/portage/util/_async/SchedulerInterface.py
471 index acacf7c31..be118ae0e 100644
472 --- a/pym/portage/util/_async/SchedulerInterface.py
473 +++ b/pym/portage/util/_async/SchedulerInterface.py
474 @@ -15,7 +15,6 @@ class SchedulerInterface(SlotObject):
475 "IO_NVAL", "IO_OUT", "IO_PRI",
476 "child_watch_add",
477 "io_add_watch",
478 - "iteration",
479 "source_remove",
480 "timeout_add",