Way to kill python thread from inside thread?

Posted by user859434 on Stack Overflow See other posts from Stack Overflow or by user859434
Published on 2012-06-28T03:10:45Z Indexed on 2012/06/28 3:15 UTC
Read the original article Hit count: 103

Filed under:
|

I have some python code that currently performs expensive computation by performing the computation in parallel through many threads. For a given time period, many threads are created and started on the fly that share the same code which is explicitly stated within the run method of the thread. My question is how do I stop/kill a thread at the end of its run method? (the run is only called once) I need to do this in order to create more threads for the next batch of computation.

#Example

class someThread(threading.Thread):
    def __init__(self):
        #some init code
    def run(self):

        #Explicitly Stated Code without constant loops

        #Something performed to stop/kill this thread

© Stack Overflow or respective owner

Related posts about python

Related posts about multithreading