How to stop a SocketServer?

Daniel Fackrell dfackrell at
Tue Jun 25 10:54:52 EDT 2002


Thanks!  This is exactly what I was looking for.

For lurkers and searchers, the Python library reference (thread objects,
currently 7.5.4) gives the following:

Set the thread's daemon flag to the Boolean value daemonic. This must be
called before start() is called.

The initial value is inherited from the creating thread.

The entire Python program exits when no active non-daemon threads are left.

Daniel Fackrell (dfackrell at
When we attempt the impossible, we can experience true growth.

"Skip Montanaro" <skip at> wrote in message
news:mailman.1024958494.18742.python-list at
>     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
>     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
> consulting:

More information about the Python-list mailing list