KeyboardInterrupt catch does not shut down the socketserver

Igor Katson descentspb at gmail.com
Fri May 15 09:04:43 CEST 2009


I have problems in getting a SocketServer to shutdown. Why does this not 
actually stop the application?

from SocketServer import UnixStreamServer, BaseRequestHandler

server = UnixStreamServer('/tmp/ss.sock', BaseRequestHandler)
try:
    server.serve_forever()
except KeyboardInterrupt:
    server.shutdown()


After that the server does not respond any more, but the application hangs.

What's the proper way to shutdown the socketserver and what is my mistake?



More information about the Python-list mailing list