[PATCH 3 of 5 STABLE V2] worker: allow waitforworkers to be non-blocking
Yuya Nishihara
yuya at tcha.org
Fri Jul 29 10:14:02 EDT 2016
On Thu, 28 Jul 2016 21:50:06 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1469735827 -3600
> # Thu Jul 28 20:57:07 2016 +0100
> # Node ID 57c3b5c1b41333faa4062720ae50bf93c187ce88
> # Parent 644e4dfd02fa16e77e550113cafe4fca3d0a9c69
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r 57c3b5c1b413
> 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
> @@ -94,9 +94,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(s)
Typo. s/s/st/
Our tests have no large working copies enough to run workers.
> if st and not problem[0]:
> problem[0] = st
I'm not sure if st == 0 is guaranteed when p == 0, but Python appears to
initialize *wstatus to 0.
More information about the Mercurial-devel
mailing list