[PATCH 8 of 8 V5] worker: stop using a separate thread waiting for children

Jun Wu quark at fb.com
Mon Nov 14 21:39:11 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1478919967 0
#      Sat Nov 12 03:06:07 2016 +0000
# Node ID 977775ff43115c001579973ef09581f102b1b842
# Parent  3a463b68088ed4721b0b0a33504143b7eff65ade
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 977775ff4311
worker: stop using a separate thread waiting for children

Now that we have a SIGCHLD hander, and it could get executed when waiting
for I/O. It's no longer necessary to have a separated waitpid thread. So
just remove it.

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -13,5 +13,4 @@ import os
 import signal
 import sys
-import threading
 
 from .i18n import _
@@ -144,9 +143,7 @@ def _posixworker(ui, func, staticargs, a
     os.close(wfd)
     fp = os.fdopen(rfd, 'rb', 0)
-    t = threading.Thread(target=waitforworkers)
-    t.start()
     def cleanup():
         signal.signal(signal.SIGINT, oldhandler)
-        t.join()
+        waitforworkers()
         signal.signal(signal.SIGCHLD, oldchldhandler)
         status = problem[0]


More information about the Mercurial-devel mailing list