comparison mercurial/worker.py @ 40472:03f7d0822ec1 stable

worker: do not swallow exception occurred in main process Before, SystemExit(255) would be most likely raised since the worker processes were terminated by the main process and the status would be set to 255 in response. We should instead re-raise the exception occurred first. It's pretty hard to debug problems like the issue 6035 with no traceback.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 11 Dec 2018 22:34:07 +0900
parents c08ea1e219c0
children e10adebf8176
comparison
equal deleted inserted replaced
40471:bb5d74a35477 40472:03f7d0822ec1
211 def cleanup(): 211 def cleanup():
212 signal.signal(signal.SIGINT, oldhandler) 212 signal.signal(signal.SIGINT, oldhandler)
213 waitforworkers() 213 waitforworkers()
214 signal.signal(signal.SIGCHLD, oldchldhandler) 214 signal.signal(signal.SIGCHLD, oldchldhandler)
215 selector.close() 215 selector.close()
216 status = problem[0] 216 return problem[0]
217 if status:
218 if status < 0:
219 os.kill(os.getpid(), -status)
220 sys.exit(status)
221 try: 217 try:
222 openpipes = len(pipes) 218 openpipes = len(pipes)
223 while openpipes > 0: 219 while openpipes > 0:
224 for key, events in selector.select(): 220 for key, events in selector.select():
225 try: 221 try:
234 raise 230 raise
235 except: # re-raises 231 except: # re-raises
236 killworkers() 232 killworkers()
237 cleanup() 233 cleanup()
238 raise 234 raise
239 cleanup() 235 status = cleanup()
236 if status:
237 if status < 0:
238 os.kill(os.getpid(), -status)
239 sys.exit(status)
240 240
241 def _posixexitstatus(code): 241 def _posixexitstatus(code):
242 '''convert a posix exit status into the same form returned by 242 '''convert a posix exit status into the same form returned by
243 os.spawnv 243 os.spawnv
244 244