[Tutor] Closing SimpleXMLRPCServer properly

lawrence wang levity at gmail.com
Wed Aug 31 21:00:38 CEST 2005

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:

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

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050831/f6d5d97e/attachment.html

More information about the Tutor mailing list