Re: [Python-Dev] Proposal: standard way of defining and executing "atexit" functions...
Hi, I wrote:
def register_exit_func(func, *args, **kw): import sys previous_func = sys.exit_func
this should have been 'sys.exitfunc'. I've also misssed to note, that I placed the following line into the module init code: import sys; def _nop(): pass; sys.exitfunc = _nop Otherwise I had to use getattr(sys, 'exitfunc', None) as David suggested. Next time I should actually cut'n'paste working code instead typing from blurred memory. :-( Another point I forgot, was that you usually want to install signal handlers on unices, that handle the signal.SIGTERM, signal.SIGHUP and signal.SIGINT signals and invoke exit function to do some final cleanup. Regards, Peter
Attached you find a similar module which I have used for years. It has all the requested features, plus allows deregistration and supports a more OO-like interface. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
participants (2)
-
M.-A. Lemburg
-
pf@artcom-gmbh.de