[Python-Dev] semi-subtle atexit gotcha?

Guido van Rossum guido@beopen.com
Tue, 27 Jun 2000 16:08:42 -0500


> 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.

Yes, #1 is good enough.  I don't think there will be lots of people
bitten by this...

--Guido van Rossum (home page: http://www.python.org/~guido/)