How to stop a SocketServer?

Daniel Fackrell dfackrell at DELETETHIS.linuxmail.org
Tue Jun 25 16:54:52 CEST 2002


Skip,

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:

---
setDaemon(daemonic)
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 linuxmail.org)
When we attempt the impossible, we can experience true growth.

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