comparison mercurial/worker.py @ 30426:c27614f2dec1

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.
author Jun Wu <quark@fb.com>
date Sat, 12 Nov 2016 03:06:07 +0000
parents e8fb03cfbbde
children 0e6ce6313e47
comparison
equal deleted inserted replaced
30425:e8fb03cfbbde 30426:c27614f2dec1
9 9
10 import errno 10 import errno
11 import os 11 import os
12 import signal 12 import signal
13 import sys 13 import sys
14 import threading
15 14
16 from .i18n import _ 15 from .i18n import _
17 from . import ( 16 from . import (
18 error, 17 error,
19 util, 18 util,
136 # other exceptions are allowed to propagate, we rely 135 # other exceptions are allowed to propagate, we rely
137 # on lock.py's pid checks to avoid release callbacks 136 # on lock.py's pid checks to avoid release callbacks
138 pids.add(pid) 137 pids.add(pid)
139 os.close(wfd) 138 os.close(wfd)
140 fp = os.fdopen(rfd, 'rb', 0) 139 fp = os.fdopen(rfd, 'rb', 0)
141 t = threading.Thread(target=waitforworkers)
142 t.start()
143 def cleanup(): 140 def cleanup():
144 signal.signal(signal.SIGINT, oldhandler) 141 signal.signal(signal.SIGINT, oldhandler)
145 t.join() 142 waitforworkers()
146 signal.signal(signal.SIGCHLD, oldchldhandler) 143 signal.signal(signal.SIGCHLD, oldchldhandler)
147 status = problem[0] 144 status = problem[0]
148 if status: 145 if status:
149 if status < 0: 146 if status < 0:
150 os.kill(os.getpid(), -status) 147 os.kill(os.getpid(), -status)