Re: Gracefully exiting CLI application

2009-07-28 Thread David
Il Tue, 28 Jul 2009 14:31:56 +0100, Nobody ha scritto: > Killed by what means? > > Ctrl-C sends SIGINT which is converted to a KeyboardInterrupt exception. > This can be caught, or if it's allowed to terminate the process, any exit > handlers registered via atexit.register() will be used. > > Fo

Re: Gracefully exiting CLI application

2009-07-28 Thread Nobody
On Mon, 27 Jul 2009 22:35:01 +0200, David wrote: > I am writing a command line application, and I need to perform some > cleaning on exit even if the process is killed. How can I do that with > python? Killed by what means? Ctrl-C sends SIGINT which is converted to a KeyboardInterrupt exception.

Re: Gracefully exiting CLI application

2009-07-27 Thread Doron Tal
On Tue, Jul 28, 2009 at 12:52 AM, Jan Kaliszewski 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). Ano

Re: Gracefully exiting CLI application

2009-07-27 Thread Jan Kaliszewski
27-07-2009 Ben Finney wrote: David <71da...@libero.it> writes: I am writing a command line application, and I need to perform some cleaning on exit even if the process is killed. How can I do that with python? Write an “exit handler” function, then use ‘atexit.register’ http://docs.python.o

Re: Gracefully exiting CLI application

2009-07-27 Thread Ben Finney
David <71da...@libero.it> writes: > I am writing a command line application, and I need to perform some > cleaning on exit even if the process is killed. How can I do that with > python? Write an “exit handler” function, then use ‘atexit.register’ http://docs.python.org/library/atexit> to registe

Re: Gracefully exiting CLI application

2009-07-27 Thread Jan Kaliszewski
27-07-2009 o 22:35:01 David <71da...@libero.it> wrote: I am writing a command line application, and I need to perform some cleaning on exit even if the process is killed. How can I do that with python? See: http://docs.python.org/library/signal.html Cheers, *j -- Jan Kaliszewski (zuo) --