[Python-Dev] Proposal: standard way of defining and executing "atexit" functions...
Peter Funk
pf@artcom-gmbh.de
Tue, 20 Jun 2000 10:08:16 +0200 (MEST)
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