I just tried changing this so that I now have a threading.Event() called self.done, which is set within the body of the shutdown() method. The serverWrapper loop now looks like this:
def serverWrapper(): while True: server.handle_request() if self.done.isSet(): break This works, but only if I follow the shutdown() rpc call a few seconds later with ... something else to cause handle_request() to complete again. Obviously, not quite the right approach.... On Dec 5, 2:00 pm, Bret <[EMAIL PROTECTED]> wrote: > 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 -- http://mail.python.org/mailman/listinfo/python-list