Skip to content

Commit cb68f36

Browse files
committed
Fix fd leak on git cmd.
Currently if command is called with as_proces=True, pipes for the command will not be closed. This change makes sure to close command file descriptors.
1 parent 6e86f8a commit cb68f36

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

git/cmd.py

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def __init__(self, proc, args ):
7373
self.args = args
7474

7575
def __del__(self):
76+
self.proc.stdout.close()
77+
self.proc.stderr.close()
78+
7679
# did the process finish already so we have a return code ?
7780
if self.proc.poll() is not None:
7881
return
@@ -100,6 +103,8 @@ def wait(self):
100103
101104
:raise GitCommandError: if the return status is not 0"""
102105
status = self.proc.wait()
106+
self.proc.stdout.close()
107+
self.proc.stderr.close()
103108
if status != 0:
104109
raise GitCommandError(self.args, status, self.proc.stderr.read())
105110
# END status handling

0 commit comments

Comments
 (0)