comparison tests/test-worker.t @ 45825:8f07f5a9c3de

worker: raise exception instead of calling sys.exit() with child's code When a worker process returns an error code, we would call `sys.exit()` with that exit code on the main process. The `SystemExit` exception would then get caught in `scmutil.callcatch()`, which would return that error code. The comment there says "Commands shouldn't sys.exit directly", which I agree with. This patch changes it so we raise a specific exception when a worker fails so we can catch instead. I think that means that `SystemExit` is now always an internal error. (I had earlier thought that this call to `sys.exit()` was from within the child process until Matt Harbison made me look again, so thanks for that!) Differential Revision: https://phab.mercurial-scm.org/D9287
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 07 Nov 2020 21:50:28 -0800
parents 12491abf93bd
children 64faa55716f4
comparison
equal deleted inserted replaced
45824:9ac96b9fa76e 45825:8f07f5a9c3de
83 start 83 start
84 abort: known exception 84 abort: known exception
85 [255] 85 [255]
86 86
87 $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \ 87 $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \
88 > test 100000.0 abort --traceback 2>&1 | egrep '(SystemExit|Abort)' 88 > test 100000.0 abort --traceback 2>&1 | egrep '(WorkerError|Abort)'
89 raise error.Abort(b'known exception') 89 raise error.Abort(b'known exception')
90 mercurial.error.Abort: known exception (py3 !) 90 mercurial.error.Abort: known exception (py3 !)
91 Abort: known exception (no-py3 !) 91 Abort: known exception (no-py3 !)
92 SystemExit: 255 92 raise error.WorkerError(status)
93 mercurial.error.WorkerError: 255
93 94
94 Traceback must be printed for unknown exceptions 95 Traceback must be printed for unknown exceptions
95 96
96 $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \ 97 $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \
97 > test 100000.0 exc 2>&1 | grep '^Exception' 98 > test 100000.0 exc 2>&1 | grep '^Exception'