changeset 30412:7bc25549e084

worker: allow waitforworkers to be non-blocking This patch adds a boolean flag to waitforworkers and makes it non-blocking if set to True. This is to make it possible that we can reap our workers while keep other unrelated children untouched, after receiving SIGCHLD.
author Jun Wu <quark@fb.com>
date Thu, 28 Jul 2016 20:57:07 +0100
parents 47de34f79f93
children 9c25a1a8c685
files mercurial/worker.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/worker.py	Thu Jul 28 20:51:20 2016 +0100
+++ b/mercurial/worker.py	Thu Jul 28 20:57:07 2016 +0100
@@ -97,9 +97,11 @@
             except OSError as err:
                 if err.errno != errno.ESRCH:
                     raise
-    def waitforworkers():
+    def waitforworkers(blocking=True):
         for pid in pids:
-            st = _exitstatus(os.waitpid(pid, 0)[1])
+            p, st = os.waitpid(pid, 0 if blocking else os.WNOHANG)
+            if p:
+                st = _exitstatus(st)
             if st and not problem[0]:
                 problem[0] = st
                 killworkers()