From 9f6ad12cbbea42c06b92d08e336ce5c7091a9227 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 15 Aug 2010 17:22:36 -0700 Subject: [PATCH] Remove PollScheduler._schedule_waitpid() since this case isn't triggered anymore, now that PollScheduler._unregister() has be fixed to discard unhandled events (so that reallocation of file descriptors no longer triggers erroneous delivery of stale events). --- pym/_emerge/PollScheduler.py | 29 +---------------------------- pym/_emerge/QueueScheduler.py | 3 +-- pym/_emerge/Scheduler.py | 2 -- pym/_emerge/SubProcess.py | 2 +- 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index ce971282f..2a77f869e 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -16,7 +16,7 @@ from _emerge.PollSelectAdapter import PollSelectAdapter class PollScheduler(object): class _sched_iface_class(SlotObject): - __slots__ = ("register", "schedule", "schedule_waitpid", "unregister") + __slots__ = ("register", "schedule", "unregister") def __init__(self): self._max_jobs = 1 @@ -228,33 +228,6 @@ class PollScheduler(object): return event_handled - def _schedule_waitpid(self, pid): - """ - Schedule until waitpid returns process status - for the given pid, and return the result from waitpid. - This is meant to be called as a last resort, since - it won't return until the process exits. This can raise - OSError from the waitpid call (typically errno.ECHILD). - @type pid: int - @param pid: the pid of the child process to wait for - """ - event_handlers = self._poll_event_handlers - - try: - while event_handlers: - f, event = self._next_poll_event() - handler, reg_id = event_handlers[f] - handler(f, event) - wait_retval = os.waitpid(pid, os.WNOHANG) - if wait_retval != (0, 0): - return wait_retval - self._schedule() - except StopIteration: - pass - - # Once scheduling is exhaused, do a blocking waitpid. - return os.waitpid(pid, 0) - _can_poll_device = None def can_poll_device(): diff --git a/pym/_emerge/QueueScheduler.py b/pym/_emerge/QueueScheduler.py index a65a90f06..8e1837c03 100644 --- a/pym/_emerge/QueueScheduler.py +++ b/pym/_emerge/QueueScheduler.py @@ -21,8 +21,7 @@ class QueueScheduler(PollScheduler): self.sched_iface = self._sched_iface_class( register=self._register, schedule=self._schedule_wait, - unregister=self._unregister, - schedule_waitpid=self._schedule_waitpid) + unregister=self._unregister) self._queues = [] self._schedule_listeners = [] diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 8d00a6f92..ae9cbcaa8 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -78,7 +78,6 @@ class Scheduler(PollScheduler): class _iface_class(SlotObject): __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge", "dblinkElog", "dblinkEmergeLog", "fetch", "register", "schedule", - "schedule_waitpid", "scheduleSetup", "scheduleUnpack", "scheduleYield", "unregister") @@ -211,7 +210,6 @@ class Scheduler(PollScheduler): dblinkEmergeLog=self._dblink_emerge_log, fetch=fetch_iface, register=self._register, schedule=self._schedule_wait, - schedule_waitpid=self._schedule_waitpid, scheduleSetup=self._schedule_setup, scheduleUnpack=self._schedule_unpack, scheduleYield=self._schedule_yield, diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 177ae3f92..0013d7391 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -92,7 +92,7 @@ class SubProcess(AbstractPollTask): self._set_returncode(wait_retval) else: try: - wait_retval = self.scheduler.schedule_waitpid(self.pid) + wait_retval = os.waitpid(self.pid, 0) except OSError as e: if e.errno != errno.ECHILD: raise -- 2.26.2