Fix resource leak in git_log utility module

Resolve a resource leak I encountered in credits_git_gen.py during
development, where it could exit with an OSError: "Too many open files".
This commit is contained in:
Campbell Barton
2023-08-04 14:32:48 +10:00
parent 9ba38d5bb6
commit ed6e24b176

View File

@@ -55,11 +55,11 @@ class GitCommit:
) + args
# print(" ".join(cmd))
p = subprocess.Popen(
with subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
)
return p.stdout.read()
) as p:
return p.stdout.read()
@property
def sha1_short(self):
@@ -71,11 +71,11 @@ class GitCommit:
"--short",
self.sha1,
)
p = subprocess.Popen(
with subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
)
return p.stdout.read().strip().decode('ascii')
) as p:
return p.stdout.read().strip().decode('ascii')
@property
def author(self):