Queue() question. This post is pretty long.

Piet van Oostrum piet at cs.uu.nl
Thu Apr 16 20:46:48 CEST 2009

>>>>> grocery_stocker <cdalten at gmail.com> (g) wrote:

>g> [cdalten at localhost ~]$ python
>g> Python 2.4.3 (#1, Oct  1 2006, 18:00:19)
>g> [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2
>g> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import Queue
>>>>> queue = Queue.Queue()
>>>>> while 1:
>g> ...    item = queue.get()
>g> ...    if item == 'done':
>g> ...       break
>g> ...
>g> this
>g> is
>g> a
>g> test
>g> done

>g> [3]+  Stopped                 python
>g> [cdalten at localhost ~]$ kill %3

>g> It appears that only item = queue.get() called. Ie, the block never
>g> advances to if item == 'done':
>g> like in the first example

You don't put anything in the queue here. The lines that you type there
don't get magically into the queue. So therefore the queue.get blocks.
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org

More information about the Python-list mailing list