SimpleXMLRPCServer interruptable?

Bret bret.wortman at gmail.com
Wed Dec 5 16:00:06 EST 2007


I'm coming back to Python after an absence and it's surprising how
many things I've forgotten since wandering (against my will) into Java
land.

Anyway, I have a need for a way to make SimpleXMLRPCServer
interruptable.  Basically, I have a main server that, in response to
certain RPC calls, creates additional servers on different ports.  I
then need to be able to shut these additional servers down.

I've got something like this in the __init__ of the class which
contains the spawned servers:

def __init__(self, host, port):
    :
    :
    server = SimpleXMLRPCServer((host, port))
    :
    : Bunch of server.register_function calls
    :
    def serverWrapper():
        try:
            while True:
                server.handle_request()
        except:
            pass

One of the methods that I register is:

def shutdown(self):
    raise "Quitting time"

Through watching logs and such I can see that the shutdown() method is
getting called, but the loop isn't getting broken.  I've done
something like this before in a previous job (so I don't have my
source in front of me, more's the pity) and am hoping someone can
chime in with a good idea.

Thanks in advance!


Bret Wortman



More information about the Python-list mailing list