Multi thread reading a file
Paul Rubin
http
Thu Jul 2 23:55:12 EDT 2009
"Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> writes:
> We're talking about the iter() builtin behavior, and that uses ==
> internally.
Oh, I see. Drat.
> It could have used an identity test, and that would be better for this
> specific case. But then iter(somefile.read, '') wouldn't work.
Yeah, it should allow supplying a predicate instead of using == on
a value. How about (untested):
from itertools import *
...
for row in takewhile(lambda x: x is sentinel,
starmap(in_queue.get, repeat(()))):
...
More information about the Python-list
mailing list