Merge pull request #258 from DiptoChakrabarty/kube_config

closes open file descriptors to prevent leaks
This commit is contained in:
Kubernetes Prow Robot 2021-10-15 10:16:56 -07:00 committed by GitHub
commit 51460f46c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,8 @@ def _create_temp_file_with_content(content, temp_file_path=None):
return _temp_files[content_key]
if temp_file_path and not os.path.isdir(temp_file_path):
os.makedirs(name=temp_file_path)
_, name = tempfile.mkstemp(dir=temp_file_path)
fd, name = tempfile.mkstemp(dir=temp_file_path)
os.close(fd)
_temp_files[content_key] = name
with open(name, 'wb') as fd:
fd.write(content.encode() if isinstance(content, str) else content)