小编NRS*_*NRS的帖子

如何中断/停止/结束挂起的多线程 python 程序

我有一个 python 程序,它实现了这样的线程:

   class Mythread(threading.Thread):
        def __init__(self, name, q):
            threading.Thread.__init__(self)
            self.name = name
            self.q = q

        def run(self):
            print "Starting %s..." % (self.name)
            while True:
                ## Get data from queue
                data = self.q.get()
                ## do_some_processing with data ###
                process_data(data)
                ## Mark Queue item as done
                self.q.task_done()
            print "Exiting %s..." % (self.name)


    def call_threaded_program():
        ##Setup the threads. Define threads,queue,locks 
        threads = []    
        q = Queue.Queue()
        thread_count = n #some number
        data_list = [] #some data list containing data

        ##Create Threads
        for …
Run Code Online (Sandbox Code Playgroud)

python multithreading interrupt hung

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

hung ×1

interrupt ×1

multithreading ×1

python ×1