From 95e2e85af5928546b92b9fe06554b48db7f3baaf Mon Sep 17 00:00:00 2001 From: DiptoChakrabarty Date: Fri, 15 Oct 2021 19:14:37 +0530 Subject: [PATCH] closes open file descriptors to prevent leaks --- config/kube_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/kube_config.py b/config/kube_config.py index 584b8a4..e5368f4 100644 --- a/config/kube_config.py +++ b/config/kube_config.py @@ -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)