Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:在Python中多次调用queue.task_done()_Python_Multithreading_Queue - Fatal编程技术网

错误:在Python中多次调用queue.task_done()

错误:在Python中多次调用queue.task_done(),python,multithreading,queue,Python,Multithreading,Queue,我在这件事上有一段时间了 class ThreadingPower(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue= queue def run(self): while True: Manager = self.queue.get() for Numbers,HWID in Manager:

我在这件事上有一段时间了

class ThreadingPower(threading.Thread):
def __init__(self, queue):
    threading.Thread.__init__(self)
    self.queue= queue

def run(self):
    while True:
        Manager = self.queue.get()
        for Numbers,HWID in Manager:
            r = requests.post(URL, data=payload) # License Checker Required Numbers ( Buyer Code ) And HWID ( License Code )
            data = (r.text)
            if ('Verified' in data):
                with open(resultsFile,'a+') as results: 
                    results.write("The Number : "+str(Numbers)+" Is Verified By The "+str(HWID))
                results.close()
                print str(HWID)+" Is Server Verified"
                active =+ 1
                self.queue.task_done()
            else:
                print str(HWID)+" Is Not Server Verified"
                self.queue.task_done()


if __name__ == "__main__":
    for i in range(10):
        t = ThreadingPower(queue)
        t.setDaemon(False)
        t.start()

    queue.put(credentials)
    queue.join()
凭据如下所示:

[
 ['UniqueHWID', 'BuyerCode'], 
 ['UniqueHWID', 'BuyerCode'], 
 ['UniqueHWID', 'BuyerCode']
]
它不断出现许多呼叫错误

问题:错误:多次调用queue.task_done()

.task\u done()
的调用应与
.queue.get()
同步
for…
循环中多次执行
.task\u done()

将代码更改为:

while True:
    Manager = self.queue.get()
    for Numbers,HWID in Manager:
        ...
        if ('Verified' in data):
            ...
            active =+ 1
        else:
            print str(HWID)+" Is Not Server Verified"

    self.queue.task_done()

多谢各位