[PATCH 4 of 4] worker: print traceback for uncaught exception unconditionally

Yuya Nishihara yuya at tcha.org
Sat Apr 15 06:18:38 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1492229095 -32400
#      Sat Apr 15 13:04:55 2017 +0900
# Node ID 7c455aa99683ec6f7f24c24e11aaadfb3fe32fe3
# Parent  535303fbc0cbdaa0c02a5aec441625c6e9b7b07d
worker: print traceback for uncaught exception unconditionally

This is what a Python interpreter would do if there were no os._exit().

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -159,7 +159,7 @@ def _posixworker(ui, func, staticargs, a
                 os._exit(255)
             except: # never return, therefore no re-raises
                 try:
-                    ui.traceback()
+                    ui.traceback(force=True)
                     ui.flush()
                 finally:
                     os._exit(255)
diff --git a/tests/test-worker.t b/tests/test-worker.t
--- a/tests/test-worker.t
+++ b/tests/test-worker.t
@@ -13,12 +13,18 @@ Test UI worker interaction
   >         # by first worker for test stability
   >         raise error.Abort('known exception')
   >     return runme(ui, [])
+  > def exc(ui, args):
+  >     if args[0] == 0:
+  >         # by first worker for test stability
+  >         raise Exception('unknown exception')
+  >     return runme(ui, [])
   > def runme(ui, args):
   >     for arg in args:
   >         ui.status('run\n')
   >         yield 1, arg
   > functable = {
   >     'abort': abort,
+  >     'exc': exc,
   >     'runme': runme,
   > }
   > cmdtable = {}
@@ -76,3 +82,9 @@ Known exception should be caught, but pr
   > test 100000.0 abort --traceback 2>&1 | grep '^Traceback'
   Traceback (most recent call last):
   Traceback (most recent call last):
+
+Traceback must be printed for unknown exceptions
+
+  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \
+  > test 100000.0 exc 2>&1 | grep '^Traceback'
+  Traceback (most recent call last):


More information about the Mercurial-devel mailing list