[Python-Dev] semi-subtle atexit gotcha?

Skip Montanaro skip@mojam.com (Skip Montanaro)
Tue, 27 Jun 2000 12:11:33 -0500 (CDT)


In thinking about the new atexit module a little more, it occurred to me
that I've handled the case where the atexit module gets loaded after another 
module that wants to set sys.exitfunc (it just incorporates that function
into its list of functions), but not if atexit gets loaded before another
modules that uses sys.exitfunc.  I see two possible choices:

    1. Punt and put a bit of verbiage in the atexit section of the library
       reference manual and the 1.6 release notes.

    2. Have atexit.register check each time it's called to see if
       sys.exitfunc is what it expects.  This isn't a perfect solution for a 
       couple reasons.  One, there's no guarantee that other sys.exitfunc- 
       modifying code isn't executed after the last call to
       atexit.register.  Two, there's no guarantee that the other code
       doesn't attempt to be "intelligent" in a fashion similar to atexit
       (can you say dueling banjos?).

I vote for option number one since there appears to be no guaranteed way to
make it work, but I'm open to other suggestions.

-- 
Skip Montanaro, skip@mojam.com, http://www.mojam.com/, http://www.musi-cal.com/
On Phil Jackson's ability to manage multiple Lakers superstars, Shaquille
O'Neal said: "He's got the rings.  I listen to the man with the rings."