The optimization in SVN rev 38556 seems to have changed
Popen.communicate's behavior when stdout is subprocess.PIPE (and maybe
for other cases as well).
See the attached file. In Python 2.4.5, all three counts are the same.
In Python 2.5.2, the middle count has increased by 1. In other words: A
file descriptor is leaked until the last reference to the Popen instance
is dropped.
I don't know a lot about the matter at hand, that's why I'm not gonna
append a patch.
On "_communicate()" after a pipe is read it's closed, doing the same on
"communicate()" seems to solve the issue of the extra pipe:
"""
if [self.stdin, self.stdout, self.stderr].count(None) >= 2:
stdout = None
stderr = None
if self.stdin:
if input:
self.stdin.write(input)
self.stdin.close()
elif self.stdout:
stdout = self.stdout.read()
+ self.stdout.close()
elif self.stderr:
stderr = self.stderr.read()
+ self.stderr.close()
self.wait()
return (stdout, stderr)
"""
Tested on "Python 2.6a2+ (trunk:62767M, May 19 2008, 13:11:07)".