worker: print traceback for uncaught exception unconditionally
authorYuya Nishihara <yuya@tcha.org>
Sat, 15 Apr 2017 13:04:55 +0900
changeset 32043 b844d0d367e2
parent 32042 8f8ad0139b8b
child 32044 cde72a195f32
worker: print traceback for uncaught exception unconditionally This is what a Python interpreter would do if there were no os._exit().
mercurial/worker.py
tests/test-worker.t
--- a/mercurial/worker.py	Sat Apr 15 13:27:44 2017 +0900
+++ b/mercurial/worker.py	Sat Apr 15 13:04:55 2017 +0900
@@ -159,7 +159,7 @@
                 os._exit(255)
             except: # never return, therefore no re-raises
                 try:
-                    ui.traceback()
+                    ui.traceback(force=True)
                     ui.flush()
                 finally:
                     os._exit(255)
--- a/tests/test-worker.t	Sat Apr 15 13:27:44 2017 +0900
+++ b/tests/test-worker.t	Sat Apr 15 13:04:55 2017 +0900
@@ -13,12 +13,18 @@
   >         # 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 @@
   > 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):