Gracefull application exit.

Robert Rawlins robert.rawlins at thinkbluemedia.co.uk
Thu Jul 24 12:06:06 EDT 2008


Chaps,

 

I'm looking to implement an exit/termination process for an application
which can be triggered by A) a keyboard interrupt or B) termination of the
application as a Daemon using a signal.

 

I have a whole bunch of tasks I want to perform as a cleanup before the
application is terminated, cleaning files, database calls, closing open
connections and a few other things.

 

I know we have:

 

# I'm the main application started method.

if __name__ == "__main__":

 

For starting an application, but do we have an equivalent methods for when
an application is terminated which we can use to close down any current
internal processes before the application exits?

 

I'd really love to have your thoughts and experience on gracefully killing
an application.

 

Robert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080724/5e313dae/attachment.html>


More information about the Python-list mailing list