EventLoop: wakeup poll loop to receive sigchild
authorZac Medico <zmedico@gentoo.org>
Fri, 17 Feb 2012 03:08:07 +0000 (19:08 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 17 Feb 2012 03:08:07 +0000 (19:08 -0800)
TODO: Find out why SIGCHLD signals aren't delivered during poll calls,
forcing us to wakeup in order to receive them. This fixes random hangs
in poll calls since commit 1979a6cdfcd8c6bae4565982d82d862be07ba5be.

pym/portage/util/_eventloop/EventLoop.py

index 9ca529fe11fbcb72b6eb8d8ff9e2ddab1203d316..e38134258c3c9d6dc988b76a53bd2d5ed050842a 100644 (file)
@@ -19,6 +19,10 @@ class EventLoop(object):
 
        supports_multiprocessing = True
 
+       # TODO: Find out why SIGCHLD signals aren't delivered during poll
+       # calls, forcing us to wakeup in order to receive them.
+       _sigchld_interval = 250
+
        class _child_callback_class(SlotObject):
                __slots__ = ("callback", "data", "pid", "source_id")
 
@@ -185,7 +189,14 @@ class EventLoop(object):
 
                if not self._poll_event_queue:
                        if may_block:
-                               timeout = self._timeout_interval
+                               if self._child_handlers:
+                                       if self._timeout_interval is None:
+                                               timeout = self._sigchld_interval
+                                       else:
+                                               timeout = min(self._sigchld_interval,
+                                                       self._timeout_interval)
+                               else:
+                                       timeout = self._timeout_interval
                        else:
                                timeout = 0
                        try: