multiprocessing: queue.get() blocks even if queue.qsize() != 0

Paul Rubin http
Tue Oct 21 10:10:32 CEST 2008

redbaron <ivanov.maxim at> 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:
         result = qresult.get_nowait()
       except Empty:

More information about the Python-list mailing list