Patchwork [STABLE] worker: do not swallow exception occurred in main process

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 11, 2018, 1:50 p.m.
Message ID <da41e2e94cfdddce1277.1544536202@mimosa>
Download mbox | patch
Permalink /patch/37110/
State New
Headers show

Comments

Yuya Nishihara - Dec. 11, 2018, 1:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1544535247 -32400
#      Tue Dec 11 22:34:07 2018 +0900
# Branch stable
# Node ID da41e2e94cfdddce12778d460d53cc7867f69f10
# Parent  4265bfb53dd3c8961993a8af8a41691bcf03d6d7
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.

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -213,11 +213,7 @@  def _posixworker(ui, func, staticargs, a
         waitforworkers()
         signal.signal(signal.SIGCHLD, oldchldhandler)
         selector.close()
-        status = problem[0]
-        if status:
-            if status < 0:
-                os.kill(os.getpid(), -status)
-            sys.exit(status)
+        return problem[0]
     try:
         openpipes = len(pipes)
         while openpipes > 0:
@@ -236,7 +232,11 @@  def _posixworker(ui, func, staticargs, a
         killworkers()
         cleanup()
         raise
-    cleanup()
+    status = cleanup()
+    if status:
+        if status < 0:
+            os.kill(os.getpid(), -status)
+        sys.exit(status)
 
 def _posixexitstatus(code):
     '''convert a posix exit status into the same form returned by