classification
Title: atexit errors should result in nonzero exit code
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.3, Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: BreamoreBoy, amaury.forgeotdarc, aminusfu, benjamin.peterson, christian.heimes, gvanrossum, lakin.wecker, titus, ysj.ray
Priority: normal Keywords:

Created on 2007-10-10 19:56 by aminusfu, last changed 2011-03-30 13:57 by ysj.ray.

Files
File name Uploaded Description Edit
ghop-215-py2.6-ctb.diff titus, 2008-01-08 10:47 Working patch with doc+test against latest trunk. review
Messages (9)
msg56323 - (view) Author: Robert Brewer (aminusfu) Date: 2007-10-10 19:56
While debugging/fixing the logging module's atexit behavior (see
http://www.cherrypy.org/ticket/646 -- it chokes atexit if stdout is
closed), it became difficult to write an automated test that verified
the bug occurred, since it happened at program exit. Returning a nonzero
exit code when atexit errors occur would be preferable to just printing
the error. Of course, if SystemExit is already raised, we should
propagate that out, but other exceptions should print the traceback and
then return some other code IMO.
msg56324 - (view) Author: Lakin Wecker (lakin.wecker) Date: 2007-10-10 20:03
I am an agreeance with the original report.  I just finished writing an
automated test that did the following to work around this behavior:

 	46	        # Sometimes an exception happens during exit, try to make
sure we get   
 	47	        # a non_zero exit code. 
 	48	        old_exitfunc = sys.exitfunc 
 	49	        def exitfunc(): 
 	50	            try: 
 	51	                old_exitfunc() 
 	52	            except SystemExit: 
 	53	                raise 
 	54	            except: 
 	55	                raise SystemExit(1)
msg56325 - (view) Author: Lakin Wecker (lakin.wecker) Date: 2007-10-10 20:04
sorry for the noise and duplication.  The full code listing should have
been:

 	46	        # Sometimes an exception happens during exit, try to make
sure we get   
 	47	        # a non_zero exit code. 
 	48	        old_exitfunc = sys.exitfunc 
 	49	        def exitfunc(): 
 	50	            try: 
 	51	                old_exitfunc() 
 	52	            except SystemExit: 
 	53	                raise 
 	54	            except: 
 	55	                raise SystemExit(1) 
 	56	        sys.exitfunc = exitfunc
msg57677 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-20 00:51
The issue should be addressed in the C code.
msg59529 - (view) Author: Titus Brown (titus) Date: 2008-01-08 10:47
Please see GHOP patches by anders_v...@yahoo.se,

http://code.google.com/p/google-highly-open-participation-psf/issues/detail?id=215

I've attached the Python 2.6 patch here.
msg67043 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-05-18 21:18
I'm assigning this to Christian because he was doing the GHOP review.
msg116780 - (view) Author: Mark Lawrence (BreamoreBoy) Date: 2010-09-18 14:05
Can someone please review the attached patch with a view to committing, it contains doc and unit test changes.
msg117159 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-09-22 23:20
exit code = 128 + # of failed atexits

I don't agree with the feature. Do we need something so complex?
msg132590 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-30 13:57
I think there is no need to implement this in python2.x since it's a  behavior change which could introduce some compatibility issues to someone's code, besides in 2.x both sys.exitfunc and atexit module should be considered, that makes the code looks complex. The sys.exitfunc is removed in 3.x.

+1 on only implementing it in 3.3.
History
Date User Action Args
2011-03-30 13:57:52ysj.raysetnosy: + ysj.ray

messages: + msg132590
versions: + Python 3.3
2010-09-22 23:20:59amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg117159
2010-09-18 14:05:06BreamoreBoysetversions: - Python 2.6
nosy: + BreamoreBoy

messages: + msg116780

stage: patch review
2010-06-09 22:19:50terry.reedysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.5, Python 2.4, Python 3.0
2008-05-18 21:18:24benjamin.petersonsetassignee: gvanrossum -> christian.heimes
messages: + msg67043
nosy: + benjamin.peterson
2008-01-08 10:47:08titussetfiles: + ghop-215-py2.6-ctb.diff
nosy: + titus
messages: + msg59529
2007-11-20 00:51:03christian.heimessetpriority: normal
assignee: gvanrossum
messages: + msg57677
nosy: + christian.heimes, gvanrossum
2007-10-10 20:04:47lakin.weckersetmessages: + msg56325
2007-10-10 20:03:54lakin.weckersetnosy: + lakin.wecker
messages: + msg56324
2007-10-10 19:56:26aminusfucreate