thread, threading; how to kill a thread?
Aaron Bingham
bingham at cenix-bioscience.com
Wed Nov 17 11:32:08 EST 2004
Jerry Sievers wrote:
>I have limited experience with threaded apps and plenty with old style
>forked heavyweight multi-processing apps.
>
>Wondering if there is a simple way from a main python program to kill
>a running thread?
>
There is no way to 'kill' a thread in Python. You will need to do
something like
def timedLoop():
while not done:
time.sleep(10)
doSomething()
Clearly, done should be implemented as an instance variable of the
thread object rather than a global, and it should probably be set by a
setDone() method that does any necessary locking. And yes, the thread
will not terminate immediately, but only the next time the loop test is
executed.
Aaron
More information about the Python-list
mailing list