
Am 19.01.2010 21:20, schrieb cool-RR:
On Tue, Jan 19, 2010 at 11:10 PM, Simon Brunning <simon@brunningonline.net <mailto:simon@brunningonline.net>> wrote:
2010/1/19 cool-RR <cool-rr@cool-rr.com <mailto:cool-rr@cool-rr.com>>: > Is there a reason that queues don't have an `__iter__` method? I mean both > `Queue.Queue` and `multiprocessing.Queue`.
Could it be made threadsafe?
-- Cheers, Simon B.
For me, iterating on the queue means just calling `get` repeatedly until it's empty. Now that I think about it, maybe this is not the most obvious meaning? I'm not sure now.
Your obvious queue iterator would call get(block=False) and stop on Empty. The other obvious meaning is be to call get(block=True) forever. IMO they are both too "obvious" to make a call -- an explicit while loop is better. Georg