How to stop a SocketServer?
Skip Montanaro
skip at pobox.com
Mon Jun 24 18:36:16 EDT 2002
Daniel> I faced this problem with a simple chat server I wrote. I
Daniel> expected that termination of the server with <ctrl-C> should
Daniel> have stopped it immediately, but it instead waits until some
Daniel> communication is received from each thread that was stopped at a
Daniel> read().
Just make all the non-main threads daemon threads. I believe the main
thread will be the one to catch the Ctrl-C. It can then cleanup and exit.
Assuming it's the only non-daemon thread, the application will also exit.
--
Skip Montanaro
skip at pobox.com
consulting: http://manatee.mojam.com/~skip/resume.html
More information about the Python-list
mailing list