subprocess -- broken pipe error

7stud bbxx789_05ss at yahoo.com
Mon Jul 2 22:34:32 CEST 2007


On Jul 2, 2:12 pm, Steve Holden <s... at holdenweb.com> wrote:
> a) Who told you pipes should be unbuffered by default, and b) what difference
> does that make anyway?
>

a) The docs.

b) If the pipes were buffered then writing a small amount of data like
"text3" to the pipe would cause the other side to hang forever thereby
providing a possible explanation for the results.

>
> > It just hangs, and then when I hit Ctrl+C and look in the file, the
> > data isn't in there.
>
> Of course it does, for the reasons mentioned above. file.read() only
> returns when it has consumed *all* the data from the file (which means
> the write must close the file for the reader to be able to return).
>

That doesn't seem like a very good explanation, since the only thing
written to the file(i.e. stdin) was "text3", and the write() was
unbuffered, so the read() could consume all the data without the
write() closing the file--there was no more data.




More information about the Python-list mailing list