use of Queue

Alexandru Mosoi brtzsnr at gmail.com
Wed Aug 27 07:58:09 EDT 2008


On Aug 27, 2:54 pm, Jeff <jeffo... at gmail.com> wrote:

> Queue raises an Empty exception when there are no items left in the
> queue.  Put the q.get() call in a try block and exit in the except
> block.
Wrong. What if producer takes a long time to produce an item?
Consumers
will find the queue empty and exit instead of waiting.

> You can also use a condition variable to signal threads to terminate.
This is the solution I want to avoid because it duplicates Queue's
functionality.
I prefer having a clean solution with nice design to hacking Queue
class.



More information about the Python-list mailing list