Multi thread reading a file
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Jul 1 11:49:31 EDT 2009
Gabriel Genellina wrote:
> ...
> def convert(in_queue, out_queue):
> while True:
> row = in_queue.get()
> if row is None: break
> # ... convert row
> out_queue.put(converted_line)
These loops work well with the two-argument version of iter,
which is easy to forget, but quite useful to have in your bag
of tricks:
def convert(in_queue, out_queue):
for row in iter(in_queue.get, None):
# ... convert row
out_queue.put(converted_line)
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list