Patchwork [7,of,7,V3] worker: stop using a separate thread waiting for children

login
register
mail settings
Submitter Jun Wu
Date Aug. 4, 2016, 6:29 p.m.
Message ID <62661c8ab16a4a4eae34.1470335348@x1c>
Download mbox | patch
Permalink /patch/16099/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - Aug. 4, 2016, 6:29 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1470334264 -3600
#      Thu Aug 04 19:11:04 2016 +0100
# Node ID 62661c8ab16a4a4eae34a60fd207b521db89bd48
# Parent  d08d72f5d8bf302dd1231be410d0b23dc082eb66
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 62661c8ab16a
worker: stop using a separate thread waiting for children

Now we have SIGCHLD hander, and it gets executed when waiting for I/O.
It's no longer necessary to have a separate waitpid thread.

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -12,7 +12,6 @@  import itertools
 import os
 import signal
 import sys
-import threading
 
 from .i18n import _
 from . import error
@@ -133,11 +132,9 @@  def _posixworker(ui, func, staticargs, a
     pids.reverse()
     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]
         if status: