我有一个名为“IterQueue”的类,它是一个iter队列:
IterQueue.py
from multiprocessing import Process, Queue, Pool
import queue
class IterQueue(queue.Queue):
def __init__(self):
self.current = 0
self.end = 10000
def __iter__(self):
self.current = 0
self.end = 10000
while True:
yield self.get()
def __next__(self):
if self.current >= self.end:
raise StopIteration
current = self.current
self.current += 1
return current
我以不同的流程将项目放入其中:
modulexxx.py
...
self.q1= IterQueue()
def function(self):
x = 1
while True:
x = x + 1
self.q1.put(x)
一切正常,但python给了我一个错误:
'IterQueue' object has no attribute 'not_full
我搜索了这个函数,所以在我的自定义队列中实现了它,但什么也没找到,
解决这个问题的办法是什么?