# HG changeset patch # User Jun Wu # Date 2016-07-28 19:57:07 # Node ID 7bc25549e0844de71eb16610d33f8e6adaca097b # Parent 47de34f79f93c11aa63bfc4646e3283483d174a9 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. diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -97,9 +97,11 @@ def _posixworker(ui, func, staticargs, a 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()