Remove PollScheduler._schedule_waitpid() since this case isn't triggered
authorZac Medico <zmedico@gentoo.org>
Mon, 16 Aug 2010 00:22:36 +0000 (17:22 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 16 Aug 2010 00:22:36 +0000 (17:22 -0700)
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
pym/_emerge/QueueScheduler.py
pym/_emerge/Scheduler.py
pym/_emerge/SubProcess.py

index ce971282ffca40816ec1488aa6e52db49490e7aa..2a77f869e909cf2e89692815d32dee918ef22914 100644 (file)
@@ -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():
index a65a90f060e86ef27e4508062777590ec4cd5045..8e1837c03245a9bb5b4c4e08acc2445a4b055fb7 100644 (file)
@@ -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 = []
index 8d00a6f9251a898c2b25e2744fadc4c38cd2232e..ae9cbcaa87ccc5e534d6196d4185deb91960508b 100644 (file)
@@ -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,
index 177ae3f927291002ef8bde50f31e6bb7aa850fc3..0013d73911957e7945616fee676d08e6db80769d 100644 (file)
@@ -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