Ending data exchange through multiprocessing pipe

Michal Chruszcz mchruszcz at gmail.com
Thu Apr 23 10:21:54 CEST 2009

On Apr 22, 6:33 pm, MRAB <goo... at mrabarnett.plus.com> wrote:
> You could do this:
>      from multiprocessing.queues import Empty
>      queue = Queue()
>      Process(target=f, args=(queue,)).start()
>      while active_children():
>          try:
>              print queue.get(timeout=1)
>          except Empty:
>              pass

This one isn't generic. When I have tasks that all finish within 0.1
seconds the above gives 10x overhead. On the other hand, if I know the
results will be available after 10 hours there's no use in checking
every second.

Best regards,
Michal Chruszcz

More information about the Python-list mailing list