get text from rogramms runn by subprocess.Popen immediatetly

Piet van Oostrum piet at cs.uu.nl
Fri Apr 17 05:05:31 EDT 2009


>>>>> Rüdiger Ranft <_rdi_ at web.de> (RR) wrote:

>RR> Hi all,
>RR> I need to call some programms and catch their stdout and stderr streams.
>RR> While the Popen class from subprocess handles the call, I get the
>RR> results of the programm not until the programm finishes. Since the
>RR> output of the programm is used to generate a progress indicator, I need
>RR> a way to acces the values written to stdout/stderr as fast as possible.

>RR> print p.stderr.read()

Use p.stderr.readline() or p.stderr.read(1) in a loop.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list