Queue() question. This post is pretty long.

grocery_stocker cdalten at gmail.com
Thu Apr 16 16:28:04 EDT 2009


On Apr 16, 11:46 am, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>>>> grocery_stocker <cdal... 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.
> --

Yeah my bad. I misread the first code -(.



More information about the Python-list mailing list