Patchwork [8,of,8,V4] worker: stop using a separate thread waiting for children

login
register
mail settings
Submitter Jun Wu
Date Nov. 12, 2016, 3:11 a.m.
Message ID <4474b3b508cb504f8132.1478920299@x1c>
Download mbox | patch
Permalink /patch/17515/
State Changes Requested
Headers show

Comments

Jun Wu - Nov. 12, 2016, 3:11 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1478919967 0
#      Sat Nov 12 03:06:07 2016 +0000
# Node ID 4474b3b508cb504f8132fad3450c94c90c3e5e6d
# Parent  7492186538a69cdfad28cb93093d7f7077942ca3
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 4474b3b508cb
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.

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -12,5 +12,4 @@  import os
 import signal
 import sys
-import threading
 
 from .i18n import _
@@ -146,9 +145,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]