subprocess.Popen does not close pipe in an error case

Nobody nobody at
Sun Jan 10 08:54:02 CET 2010

On Wed, 06 Jan 2010 19:05:40 -0800, Steven K. Wong wrote:

> Well, the example code at
> ... /subprocess.html#replacing-shell-pipeline
> has the same issue:

> Perhaps the doc can be improved to remind folks to close p1.stdout if
> the calling process doesn't need it, unless wait() is changed to close
> it and p1.wait() is called.
> Am I making any sense here?

The docs should include the p1.stdout.close().

It isn't needed in the typical case, where p2 runs until EOF on stdin, but
(as you have noticed) it matters if p2 terminates prematurely.

More information about the Python-list mailing list