A beginner's question on thread
Roger Binns
rogerb at rogerbinns.com
Tue Apr 6 03:56:26 EDT 2004
> Now my question is, how do I terminate the server thread if user wants
> to exit the application?
The easiest way is to setDaemon(True) on the thread. See the doc for
exactly what it does.
If you want to do it in a more "proper" fashion, then you have to
make the thread do a polling loop, such as by putting a short
timeout on the sockets, and then check a variable which indicates
if you should continue, looping back if not.
It would be really nice if Python supported interrupting a thread
like Java does.
Roger
More information about the Python-list
mailing list