Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit95878d2

Browse files
committed
Merge pull request#58 from sugi/cmd-fd-leak-fix
Fixes on cmd.py (fd leak and signal exception)Currently if command is called with as_proces=True, pipes for thecommand will not be closed.cb68f36 makes sure to close command file descriptors.Ignore signal exception on AutoInterrupt destructor.When command run as subprocess, AutoInterrupt will kill theprocess on destructor. However, if process already finished,it raise OSError exception.
2 parents6e86f8a +f467834 commit95878d2

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
@@ -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
ifself.proc.poll()isnotNone:
7881
return
@@ -84,6 +87,8 @@ def __del__(self):
8487
# try to kill it
8588
try:
8689
os.kill(self.proc.pid,2)# interrupt signal
90+
exceptOSError:
91+
pass# ignore error when process already died
8792
exceptAttributeError:
8893
# try windows
8994
# for some reason, providing None for stdout/stderr still prints something. This is why
@@ -100,6 +105,8 @@ def wait(self):
100105
101106
:raise GitCommandError: if the return status is not 0"""
102107
status=self.proc.wait()
108+
self.proc.stdout.close()
109+
self.proc.stderr.close()
103110
ifstatus!=0:
104111
raiseGitCommandError(self.args,status,self.proc.stderr.read())
105112
# END status handling

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp