Re: properly catch SIGTERM

2012-07-20 Thread Oscar Benjamin
What about Kushal's suggestion above? Does the following work for you? signal.signal(signal.SIGTERM, my_SIGTERM_handler) signal.siginterrupt(signal.SIGTERM, flag=False) According to the siginterrupt docs ( http://docs.python.org/library/signal.html) """ Change system call restart behaviour: if fl

Re: properly catch SIGTERM

2012-07-20 Thread Eric Frederich
On Fri, Jul 20, 2012 at 1:51 AM, Jason Friedman wrote: > > This seems to work okay but just now I got this while hitting ctrl-c > > It seems to have caught the signal at or in the middle of a call to > > sys.stdout.flush() > > > > > > --- Caught SIGTERM; Attempting to quit gracefully --- > > Trac

Re: properly catch SIGTERM

2012-07-20 Thread Kushal Kumaran
On Fri, Jul 20, 2012 at 11:39 AM, Dieter Maurer wrote: > Eric Frederich writes: >> ... >> This seems to work okay but just now I got this while hitting ctrl-c >> It seems to have caught the signal at or in the middle of a call to >> sys.stdout.flush() >> --- Caught SIGTERM; Attempting to quit gra

Re: properly catch SIGTERM

2012-07-19 Thread Dieter Maurer
Eric Frederich writes: > ... > This seems to work okay but just now I got this while hitting ctrl-c > It seems to have caught the signal at or in the middle of a call to > sys.stdout.flush() > --- Caught SIGTERM; Attempting to quit gracefully --- > Traceback (most recent call last): >   File "/hom

properly catch SIGTERM

2012-07-19 Thread Eric Frederich
So I wrote a script which acts like a daemon. And it starts with something like this ### Begin Code import signal STOPIT = False def my_SIGTERM_handler(signum, frame): global STOPIT print '\n--- Caught SIGTERM; Attempting to quit gracefully ---' STOPIT = True signal.sig