properly catch SIGTERM

Eric Frederich eric.frederich at gmail.com
Fri Jul 20 10:27:01 EDT 2012


On Fri, Jul 20, 2012 at 1:51 AM, Jason Friedman <jason at powerpull.net> 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 ---
> > Traceback (most recent call last):
> >   File "/home/user/test.py", line 125, in <module>
> >     sys.stdout.flush()
> > IOError: [Errno 4] Interrupted system call
> >
> >
> > How should I fix this?
> > Am I doing this completely wrong?
>
> Instead of rolling your own others have written Python code to
> implement daemons.  Try a search on "Python daemon".
>

I found a stackoverflow question that linked to this...
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
... I'm not sure how that would help.  They don't attempt to exit
gracefully.
I don't think my problem is the daemon part, it is the handling the SIGTERM
signal where I'm having trouble.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120720/a0966773/attachment.html>


More information about the Python-list mailing list