[issue2791] subprocess.py leaks fd in communicate

Rafael Zanella report at bugs.python.org
Mon May 19 20:08:26 CEST 2008


Rafael Zanella <rafael.zanella at yahoo.com.br> added the comment:

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)".

----------
nosy: +zanella

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2791>
__________________________________


More information about the Python-bugs-list mailing list