How to stop a SocketServer?

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Sat Jun 22 00:58:41 EDT 2002


I want to run a simple network server based on
SocketServer.ThreadingTCPServer.  I followed the docs
and implemented a handler class which works fine.  
Then I instantiate the server and run the serve_forever() method.
The server listens for connections, starts threads for them
and handles them just like it should.

Question: how do I shut down the server once it's running, besides
doing something crude like killing the process?  I'd like to be able
to connect to the server and enter a "shutdown" command and have the
server gracefully exit and free the port.  I haven't been able to
figure out how to do that.

Suggestions?  Thanks.



More information about the Python-list mailing list