[ python-Bugs-1052242 ] Attempt to run all atexit handlers

SourceForge.net noreply at sourceforge.net
Wed Oct 27 07:46:08 CEST 2004


Bugs item #1052242, was opened at 2004-10-22 09:31
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1052242&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Skip Montanaro (montanaro)
Summary: Attempt to run all atexit handlers

Initial Comment:
Currently, if an atexit handler raises an exception
during _run_exitfuncs, none of the remaining handlers
in the _exithandlers list gets run.  I would prefer it
if _run_exitfuncs did something like:

    while _exithandlers:
        func, targs, kargs = _exithandlers.pop()
        try:
            func(*targs, **kargs)
        except SystemExit:
            raise
        except:
            import sys, traceback
            print >> sys.stderr, "Error in sys.exitfunc:"
            traceback.print_exc()

The SystemExit except clause is there because it looks
like (given its special treatment in call_sys_exitfunc)
SystemExit is envisioned as a way of intentionally
breaking out of the exithandlers loop.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-10-27 00:46

Message:
Logged In: YES 
user_id=80475

I prefer the original proposal that leaves the API untouched.

Irrespective of ordering, my thought is that all exit
handlers are probably expected to run (needed for important
cleanup, resource freeing, etc) and may be independent of
one another.  So, all of them that can run, probably should.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2004-10-24 12:21

Message:
Logged In: YES 
user_id=44345

OTOH, since the ordering of the exit handlers is not guaranteed,
exiting after one exception is also reasonable behavior.  Attached
is a diff that does two things: adds a set_run_all function and
converts the functionality into an ExitHandler class to keep from
all the different bits of global state.



----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-10-23 19:56

Message:
Logged In: YES 
user_id=80475

This could be considered a bug.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1052242&group_id=5470


More information about the Python-bugs-list mailing list