killing thread ?

Laura Creighton lac at strakt.com
Fri Jan 24 07:07:41 EST 2003


> 
> Hi,
> 
> AFAIK there is no method in the threading module to kill a thread.
> Each thread has to terminate itself by watching status variables.
> But: what happens if I start a thread, and when I want to kill
> this thread, I delete all references to the according Thread object,
> and call the garbage collector. 
> Will this work ??

No.  You cannot stand outside your application and kill a thread.
Instead you have to arrange for your thread to receive the message
to go commit suicide (and then your thread has to know how to do
that).  If your threads are already communicating by Queues, sticking
a 'do_die' in there is often cleanest.  

<snip> 

> Greetings, Uwe.
> 
> -- 
> Dr. rer. nat. Uwe Schmitt      Computer science is no more about Computers,
> uwe.schmitt at num.uni-sb.de      than astronomy is about telescopes. (Dijkstra)
> http://www.procoders.net           
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Laura Creighton





More information about the Python-list mailing list