draining pipes simultaneously

Dmitry Teslenko dteslenko at gmail.com
Wed Mar 5 13:03:32 CET 2008

On Wed, Mar 5, 2008 at 1:34 PM,  <bockman at virgilio.it> wrote:
>  The Queue.get method by default is blocking. The documentation is not
>  100% clear about that (maybe it should report
>  the full python definition of the function parameters, which makes
>  self-evident the default value) but if you do
>  help(Queue.Queue) in a python shell you will see it.

>  Hence, try using a timeout or a non-blocking get (but in case of a non
>  blocking get you should add a delay in the
>  loop, or you will poll the queues at naximum speed and maybe prevent
>  the other threads from accessing them).

Thanks for advice! Finally I came up to following loop:

	while to.isAlive() or te.isAlive():
			while True:
				line = qo.get(False)
				if out_filter:
		except Queue.Empty:

			while True:
				line = qe.get(False)
				if err_filter:
		except Queue.Empty:

Inserting delay in the beginning of the loop causes feeling of command
taking long to start and delay at the end of the loop may cause of
data loss when both thread became inactive during delay.

More information about the Python-list mailing list