Gracefully exiting CLI application

Doron Tal doron.tal.list at gmail.com
Tue Jul 28 00:37:35 EDT 2009


On Tue, Jul 28, 2009 at 12:52 AM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:

> As I wrote, you must use signals. Though sometimes it's a good idea
> to combine these two techniques (i.e. signal handlers call sys.exit(),
> then sys.exitfunc/or function registered with atexit does the actual
> cleaning actions).


Another way of combining signals and atexit functions is to write a signal
handlers which update some QUIT_APP flag, which the application polls on
occasionally. This way you'll avoid deadlocks which may happen if you have a
multi-threaded application, and your main thread had just acquired a lock.

--doron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090728/1dd4b317/attachment-0001.html>


More information about the Python-list mailing list