Skip to content

Commit 9c5b87b

Browse files
committed
Merge pull request #150 from derenio/0.3
Merged fd leaks fix from the master to the 0.3 version
2 parents 9ea3dbd + b137f55 commit 9c5b87b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

git/cmd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def __init__(self, proc, args ):
7474
self.args = args
7575

7676
def __del__(self):
77+
self.proc.stdout.close()
78+
self.proc.stderr.close()
79+
7780
# did the process finish already so we have a return code ?
7881
if self.proc.poll() is not None:
7982
return
@@ -85,6 +88,8 @@ def __del__(self):
8588
# try to kill it
8689
try:
8790
os.kill(self.proc.pid, 2) # interrupt signal
91+
except OSError:
92+
pass # ignore error when process already died
8893
except AttributeError:
8994
# try windows
9095
# for some reason, providing None for stdout/stderr still prints something. This is why
@@ -101,6 +106,8 @@ def wait(self):
101106
102107
:raise GitCommandError: if the return status is not 0"""
103108
status = self.proc.wait()
109+
self.proc.stdout.close()
110+
self.proc.stderr.close()
104111
if status != 0:
105112
raise GitCommandError(self.args, status, self.proc.stderr.read())
106113
# END status handling

0 commit comments

Comments
 (0)