Shutdown hook

Lawrence Oluyede raims at dot.com
Wed Nov 16 00:08:40 CET 2005


Il 2005-11-15, Ben Finney <bignose+hates-spam at benfinney.id.au> ha scritto:
> Steve <steve.morin at gmail.com> wrote:
>> Does any one know if python has the ability to run a shutdown hook.
>
> When the Python runtime system wants to exit, it raises a SystemExit
> exception.
>
> Catch that exception at the top level of your code, and do whatever
> you like. (It might be polite to actually exit at some point, of
> course. sys.exit(exitcode) will do so -- raising another SystemExit
> exception.)
>

I think using atexit module -
http://docs.python.org/lib/module-atexit.html is cleaner



-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"



More information about the Python-list mailing list