multiprocessing: queue.get() blocks even if queue.qsize() != 0
Paul Rubin
http
Tue Oct 21 04:10:32 EDT 2008
redbaron <ivanov.maxim at gmail.com> writes:
> while qresult.qsize():
> result = qresult.get() #this code blocks!
> doWithResult(result)
That is unreliable for the reason Antoon explained, and as is
documented in the manual for the Queue module. Write instead
something like (untested):
while True:
try:
result = qresult.get_nowait()
except Empty:
break
doWithResult(result)
More information about the Python-list
mailing list