SimpleXMLRPCServer daemon

Sean DiZazzo half.italian at gmail.com
Fri Jan 29 15:04:08 EST 2010


On Jan 29, 7:54 am, Thomas Allen <thomasmal... at gmail.com> wrote:
> I have a script that runs an instance of SimpleXMLRPCServer and in
> general it works as expected. In its __del__, it is supposed to clean
> up its PID file (written on boot). I have two problems with this
> server instance: The first is that tt doesn't always clean up its PID
> file; is there a more reliable way to do this than how I am currently?
> The second is that when it does crash, I don't know about it...what
> would be sufficient as a "keep-alive" script to restart it? I suppose
> I could use something like EventMachine (already installed on my
> server) to watch the PID file if it were deleted reliably.
>
> Thomas Allen

You should check out python-daemon.  I use home grown daemons all the
time, and have only played a little with the python-daemon library,
but it is surely written well, and handles lockfiles and pidfiles.

I believe you can map a function to any signal that the daemon
receives to do any kind of cleanup etc.  Ssometimes those PID files
might be left around, but the runner included with the module (i
think) checks for stale pid files.

There's all kinds of useful stuff.

In my home grown daemons I use Adam's technique, and wrap the "while
1:" block in a try except clause.

~Sean



More information about the Python-list mailing list