Queue limitations?

Fredrik Lundh fredrik at pythonware.com
Wed Mar 15 18:26:29 CET 2006


mateom at gmail.com wrote:

> I'm using Queue to send images from one thread to another, and some of
> the images are not appearing in the consumer thread....maybe 1 in 3
> arrive. I've tried passing the image data in both string form and as a
> PIL Image object, with the same result.
>
> It does work, however, if I use zlib to compress the image string
> before passing it to Queue and then decompress it in the consumer
> thread. So, my question: Does Queue have some capacity limitation?
> (Uncompressed, my images are 786432 long... 512x512x3)

the queue holds references to the images, not the images themselves,
so the size should be completely irrelevant.

> class imageQueue(threading.Thread):
>
>     def __init__(self):
>         threading.Thread.__init__(self)
>         self.filenum = 0
>         self.theQueue = Queue.Queue(-1)
>
>     def run(self):
>         while 1:
>             # for testing, do something simple with images
>             img = self.theQueue.get()
>             imgt = Image.frombuffer('RGB',(512,512), img)
>             #imgt = Image.frombuffer('RGB',(512,512), zlib.decompress(img)) #this one works
>             imgt.save( "./imgs_out/%i.png" % self.filenum, "PNG")
>             self.filenum += 1

how many instances of the imageQueue are you using ?

</F>






More information about the Python-list mailing list