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
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():
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 = []
class _iface_class(SlotObject):
__slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge",
"dblinkElog", "dblinkEmergeLog", "fetch", "register", "schedule",
- "schedule_waitpid",
"scheduleSetup", "scheduleUnpack", "scheduleYield",
"unregister")
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,
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