Message265678
I want to set exit code of my script in a function registered in the atexit module. (See https://stackoverflow.com/q/37178636/711006.) Calling sys.exit() in that function results in the following error:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "atexit_test.py", line 3, in myexit
sys.exit(2)
SystemExit: 2
Despite the printed error, the exit code is set to 0. (This might be related with #1257.)
This problem seems to affect Python 3.x. I experienced it with Python 3.5.1 on Windows 7 x64 and I am able to reproduce it with Python 3.4.3 on Linux (x64). Python 2.7.6 on the same Linux machine works as expected: Exits without additional messages and the desired exit code is set.
A simple test case:
def myexit():
import sys
sys.exit(2)
import atexit
atexit.register(myexit) |
|
Date |
User |
Action |
Args |
2016-05-16 07:57:08 | Melebius | set | recipients:
+ Melebius |
2016-05-16 07:57:08 | Melebius | set | messageid: <1463385428.15.0.762354704325.issue27035@psf.upfronthosting.co.za> |
2016-05-16 07:57:08 | Melebius | link | issue27035 messages |
2016-05-16 07:57:07 | Melebius | create | |
|