[Tutor] Help with Python Queue
anish singh
anish198519851985 at gmail.com
Sat Nov 26 04:07:49 EST 2016
I was just writing to read a file using popen and wanted to use queue along
with it.
I have below code but it is giving this error:
AttributeError: Queue instance has no attribute 'taskdone'
import threading
from Queue import Queue
def worker(q):
while True:
dataset = q.get()
print("q is taken out")
q.taskdone()
def create_data(q):
print("Inside create data")
output = [1, 2, 3]
for i in output:
print("Inside", i)
print("queue is put")
q.put(i)
if __name__ == '__main__':
q = Queue()
t = threading.Thread(target=worker, args=(q,))
t.daemon = True
t.start()
create_data(q)
q.join()
More information about the Tutor
mailing list