Subprocess freezes when piping from stdout.

J

James McGill

Hi All,

I'm using subprocess.Popen to run a C++ compiler and have set stdout =
PIPE. The exact line of code that I am using is:

process = Popen(command, stdout=PIPE)
status = process.wait()

This works fine until a large amount of data is written to stdout.
When this occurs, my python program seems to freeze. It will no longer
run or respond to Ctrl-C. I am assuming that it is stuck waiting for
the process to end, but I'm not sure why this should take so long (I
have left it running for hours and it never ended)

At the moment the code is being executed on a Win32 environment.

Is anyone aware of why this might be occurring, or of any ways around
this? Does the PIPE implementation in Win32 have a maximum buffer
size?

Regards,
James McGill
 
F

Fredrik Lundh

James said:
Is anyone aware of why this might be occurring, or of any ways around
this? Does the PIPE implementation in Win32 have a maximum buffer
size?

pipes always have a limited buffer size, on all platforms. you're
supposed to read data from them as it arrives (e.g. by explicitly
reading from the "stdout" attribute, or by calling "communicate").

if you cannot do that, bind the channel to a file, not a pipe.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top