Success with subprocess communicate on Windows?
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Thu Jul 3 04:03:07 EDT 2014
On 07/03/2014 06:09 AM, Terry Reedy wrote:
>
> Yes, but what puzzled me is that running
> subprocess.check_output(r'pyflakes c:\programs\python34\lib')
> in the regular interpreter *does* produce output instead of the error
> message. My guess is that it fills up the pipe, so that check_output
> starts reading the pipe long before pyflakes exits with status 1.
>
> Hmm. I tried it again, and I see some but not all of the output I got at
> the command line *and* I see the exit status message. So the subprocess
> must get some of the output but then stop when it sees the exit status.
> Thanks.
>
For a partial explanation try this:
from the command line (again my path is slightly different):
pyflakes C:\Python34\lib > stdout.txt
this will still give you a few lines of output and these should be the
same ones you're seeing from the python interpreter when you're doing:
subprocess.check_output(r'pyflakes C:\Python34\lib')
==> pyflakes sends these lines to stderr instead of stdout !!
confirmation:
subprocess.check_output(r'pyflakes C:\Python34\lib', stderr=subprocess.PIPE)
and the output is gone.
So the remaining questions are:
- why on earth is pyflakes sending these lines (and only these) to stderr ?
- what is happening to the stderr output when run in IDLE ? I guess it
is caught and suppressed somewhere, but to add to your observations the
check_output call doesn't hang on IDLE, but finishes eventually with no
output other than the traceback.
Best wishes,
Wolfgang
More information about the Python-list
mailing list