Reading output from a child process non-blockingly

ilochab at gmail.com ilochab at gmail.com
Wed Jun 29 06:31:48 EDT 2005



Yuan HOng ha scritto:
> In my program I have to call an external program and parse its output.
> For that I use the os.popen2 function, and then read the output
> stream.
>
> But the complexity is that the external program gives back its output
> in a piecemeal manner, with long delays between the outputs. In the
> main program I want to therefore read the output in a non-blocking
> manner, to read as many bytes as the child process is spitting out.
>
> The question is, how can I achieve that?
> 

What about using a thread to control the child process?

Licia




More information about the Python-list mailing list