I have a SimpleXMLRPCServer, which I've tweaked thusly:

class StoppableXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
    def serve_forever(self):
        """to stop this server: register a function in the class
        that uses it which sets server.stop to True."""
        self.stop = False
        while not self.stop:
            self.handle_request()

Here's the code where I start the server...

        try:
            self.server.serve_forever()
        finally:
            self.server.server_close()
            self.log('server closed')

>From another thread, I set the server's stop attribute to False, so the server stops running. It exits the try block, runs server_close(), then I get the message 'server closed'...

...but when I try to use the port that the server's bound to again, it takes a very long time (while i try to use the port, catch the exception, sleep, try again) until it becomes free. Is there something else I need to call to ensure that the port is released cleanly? Is this an OS-specific thing out of my control? (I'm running Debian Linux.)

Thanks in advance
Lawrence
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to