[Tutor] Help with Python Queue
Alan Gauld
alan.gauld at yahoo.co.uk
Sat Nov 26 14:00:55 EST 2016
On 26/11/16 09:07, anish singh wrote:
> I have below code but it is giving this error:
> AttributeError: Queue instance has no attribute 'taskdone'
Please post the full error not just a summary.
Also please post the actual code...
> import threading
> from Queue import Queue
I get an import error here with no module named Queue.
Which Queue module are you using? Or should it be
spelled queue?
> def worker(q):
> while True:
> dataset = q.get()
> print("q is taken out")
> q.taskdone()
Assuming you meant the standard queue module then
that should be
q.task_done()
When you get an attribute error it's worth trying
dir() on the offending object:
>>> from queue import Queue as Q
>>> dir(Q)
...., task_done,....
>>> help(Q.task_done)
...
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list