socketserver question

K Richard Pixley rich at
Thu Jan 5 17:43:02 EST 2012

Once I've instantiated my server class, along with a handler class, 
called server.serve_forever(), handler.handle() has been called, I've 
done my work, and I'm ready to shut the whole thing down...

How do I do that?

The doc says server.shutdown(), but if I call self.server.shutdown() 
from within handler.handle(), I seem to get a deadlock, which is exactly 
what I'd expect in a single threaded system with no way to "signal" the 
server.server_forever() loop which is several frames up the stack.

I've also tried sys.exit() but it seems that the server object is 
catching that as an exception.

How is this expected to work?  How do I terminate the 
server.serve_forever() loop?


More information about the Python-list mailing list