[PATCH 7 of 8 V4] worker: add a SIGCHLD handler to collect worker immediately
Yuya Nishihara
yuya at tcha.org
Mon Nov 14 08:15:24 EST 2016
On Sat, 12 Nov 2016 03:11:38 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1478920042 0
> # Sat Nov 12 03:07:22 2016 +0000
> # Node ID 7492186538a69cdfad28cb93093d7f7077942ca3
> # Parent 596cee9d5c12dcfa2d272b5441d5060a26a6440c
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r 7492186538a6
> worker: add a SIGCHLD handler to collect worker immediately
>
> As planned by previous patches, add a SIGCHLD handler to get notifications
> about worker exits, and deals with worker failure immediately.
>
> diff --git a/mercurial/worker.py b/mercurial/worker.py
> --- a/mercurial/worker.py
> +++ b/mercurial/worker.py
> @@ -126,8 +126,12 @@ def _posixworker(ui, func, staticargs, a
> problem[0] = st
> killworkers()
> + def sigchldhandler(signum, frame):
> + waitforworkers(blocking=False)
> + oldchldhandler = signal.signal(signal.SIGCHLD, sigchldhandler)
> for pargs in partition(args, workers):
> pid = os.fork()
> if pid == 0:
> signal.signal(signal.SIGINT, oldhandler)
> + signal.signal(signal.SIGCHLD, oldchldhandler)
> try:
> os.close(rfd)
> @@ -147,4 +151,5 @@ def _posixworker(ui, func, staticargs, a
> signal.signal(signal.SIGINT, oldhandler)
> t.join()
> + signal.signal(signal.SIGCHLD, oldchldhandler)
I got strange error:
% hg up --trace
Traceback (most recent call last):
...
File "mercurial/merge.py", line 1187, in applyupdates
for i, item in prog:
File "mercurial/worker.py", line 159, in _posixworker
for line in fp:
IOError: [Errno 0] Error
abort: Error
Maybe something goes wrong in the buffered iterator?
iter(fp.readline, '') worked fine.
More information about the Mercurial-devel
mailing list