[Python-ideas] `__iter__` for queues?
cool-rr at cool-rr.com
Thu Jan 21 00:09:06 CET 2010
Okay Raymond. Thanks for your patience.
On Thu, Jan 21, 2010 at 12:48 AM, Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:
> On Jan 20, 2010, at 12:28 PM, cool-RR wrote:
> > Thanks for the code Raymond. However, what I use is actually simpler:
> > def iterate(queue, block=False):
> > '''Iterate over the items in the queue.'''
> > while True:
> > try:
> > yield queue.get(block=block)
> > except Queue.Empty:
> > raise StopIteration
> Then it sounds like the existing API is more than adequate for your needs.
> Dump the above fragment in your utils module and be done with it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas