The return code of python on linux/MacOS when the program is ended with a KeyboardInterrupt should be -2, when running with multiprocessing the exitcode is 1. I've attached a reproduced example.
From The Process.join() docs: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Process.exitcode
> A negative value -N indicates that the child was terminated by signal N.
output:
$ /usr/local/opt/python@3.9/bin/python3 -m test
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/awright/docker/2108/test.py", line 49, in <module>
sys.exit(main())
File "/Users/awright/docker/2108/test.py", line 41, in main
return target()
File "/Users/awright/docker/2108/test.py", line 10, in target
time.sleep(99999)
KeyboardInterrupt
proc.wait()=-2
Process SpawnProcess-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/Users/awright/docker/2108/test.py", line 10, in target
time.sleep(99999)
KeyboardInterrupt
proc.exitcode=1
See also:
https://bugs.python.org/issue1054041 and https://bugs.python.org/issue41602
|