Shutdown hook

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Nov 15 17:55:17 EST 2005


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 took it easy today. I just pretty much layed around in my |
  `\      underwear all day. ... Got kicked out of quite a few places, |
_o__)                           though."  -- Bug-Eyed Earl, _Red Meat_ |
Ben Finney



More information about the Python-list mailing list