How to kill a thread?

John Dohn john.dohn.john at gmail.com
Fri Jun 6 12:30:12 CEST 2008


Hi there,

How can I kill a threading.Thread subclass from MainThread?

My threads are waiting for data in Queue.get() method:
class MyThread(threading.Thread):
    def run(self):
        while True:
            data = queue.get()    # <- here it waits most of the time
            ... process data

>From the main thread I start several working threads:
thr = MyThread()
thr.start()
... feed the queue
and at the end for each thread I'd like to do something like thr.kill() or
thr.stop() or thr.destroy() or ... you got the point. I can't figure out
how.

Is there a way to do it?

Thanks!

JD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080606/d9264a65/attachment.html>


More information about the Python-list mailing list