[Python-Dev] Re: atexit missing an unregister method

Nick Jacobson nicksjacobson at hotmail.com
Tue Apr 26 22:40:12 CEST 2005

<< This seems like a poor argument for unregistering exit handlers.  If 
registered an exit handler, why then explicitly do what you've already asked
the system to do? >>

1. To free up memory for the rest of the program.
2. If the following block is in a loop, and you need to allocate & then 
deallocate resources multiple times.:

<< atexit.register(free_resource, x)
atexit.register(free_resource, y)
# do operations with x and y, potentially causing the program to exit
# if nothing caused the program to unexpectedly quit, close the resources
free_resource(y) >>

<<  Also, your proposed unregisterall() function would be
dangerous.  As an application writer you don't know what other parts of the
system (libraries you use, for example) might have registered exit

Skip >>

That's true...it would probably be better to expose the stack of registered 
functions.  That way you can manually unregister functions you've 

--Nick Jacobson

Express yourself instantly with MSN Messenger! Download today - it's FREE! 

More information about the Python-Dev mailing list