当某些条件在python中匹配时,如何停止或退出正在运行的线程

时间:2017-04-06 23:46:42

标签: python multithreading

如果在python中某些条件匹配时如何在以下代码中停止或退出正在运行的线程:

import threading

class RR_Client(client):
    def __init__(self,client_name):
        self.del_counter=0
        self.client_names()
    def client_names(self):
        #some code
        if (some condition):
            self.del_counter=self.del_counter+1
        if self.del_counter !=0:
            #how to exit thread and return to main before thread is 
            completed ?
        #some more code



def main():
    # some code
    t=threading.Thread(target=RR_Client, args=(client))
    t.start()

if __name__ == '__main__':
    main()

0 个答案:

没有答案