how to drop all thread ??

Chris S. chrisks at NOSPAM.udel.edu
Tue Nov 30 01:27:18 EST 2004


Leon wrote:
> if class A(
> use threading,thread module
> ) to produce 100 thread,how to drop its (100 thread) when its running 

As Roggisch suggests, the cleanest way is if the thread kills itself 
once signaled by an exit condition. However, there is a non-orthodox way 
of pseudo-forcibly killing threads by catching the kill signal in a 
traceback. This method is summed up in Connelly Barnes's informal 
KThread module:
http://www.google.com/groups?q=KThread+group:comp.lang.python&hl=en&lr=&selm=mailman.225.1083634398.25742.python-list%40python.org&rnum=1

Note it won't work in all cases, as it can't kill a thread that's made a 
blocking system call. However, it may come in useful.



More information about the Python-list mailing list