[XML-SIG] SimpleXMLRPCServer-related questions

Martin v. Loewis martin at v.loewis.de
Thu Oct 17 09:22:59 EDT 2002


"Alex @ Infinito" <alessandro.bottoni at infinito.it> writes:

> I'm playing with the SimpleXMLRPCServer and I have a few doubts:

Alex, I think few people have been confronted with these issues so
far. If it works for you, it is good.

> + How do I start the SimpleXMLRPCServer(derived) object?
> - Should I start it with inetd?

That is not supported, I believe. inetd will give the connection as
stdin/stdout, whereas SimpleXMLRPCServer will accept its own
connections.

You probably *could* make this work by inheriting from
SimpleXMLRPCRequestHandler. However, this assumes that there is a
single socket; I don't know whether passing in sys.stdin there might
work as well.

> - Or should I start it by myself, forking and chdir/umask the child process?

If you start it through /etc/rc?.d, I recommend you just create a
background process. You can then do all chdir/umask in the shell
script.

> + How do I stop the service(daemon)?

The server should probably respond to SIGINT. You can save the PID of
the process in /var/run/yourserver.pid, which you get from starting
the server in the /etc/init.d script.

> - By "KILLing" it?
> - In this case, the SimpleXMLRPCServer class (or its ancestors) provides any 
> facility to get and record the PID for later use?

If the shell forks it, it will know the PID. Alternatively, you can
use standard Python API (os.getpid), and write the .pid file yourself.

> - Or should I stop it by sending it a service shutdown request (and
> handling it inside my code)?

You would need to authenticate this request, to avoid that somebody
can kill your server remotely.

> - How do I handle the service shutdown request in the
> SimpleXMLRPCServer case?

raise SystemExit.

> - Does it have any specific needs?

It depends on your service. You may want to provide "graceful"
shutdown, ie. do not outright stop the process, but wait for the
current request to complete. Whether this is needed depends on your
application.

> + In a real-world application, should I use threads with
> SimpleXMLRPCServer?

It depends on what load you expect, and whether you expect to service
requests more quickly when using threads. Unless your service
implementation has blocking calls, threads are not needed.

> - Should I use something else (the ESO platform, for example)?

What is ESO?

I always recommend to use CORBA, instead of XML-RPC.


Regards,
Martin




More information about the Python-list mailing list