From 2c15435cf0e0f2ceea5c863b569c2f4c9e2eed41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E5=BF=97=E8=90=8D-=E6=95=B0=E6=8D=AE=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E9=83=A8?= Date: Thu, 28 Feb 2019 17:53:06 +0800 Subject: [PATCH] config temp file check existence --- config/kube_config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/kube_config.py b/config/kube_config.py index 743046db..961669b3 100644 --- a/config/kube_config.py +++ b/config/kube_config.py @@ -63,8 +63,9 @@ def _create_temp_file_with_content(content): # Because we may change context several times, try to remember files we # created and reuse them at a small memory cost. content_key = str(content) - if content_key in _temp_files: - return _temp_files[content_key] + temp_file_name = _temp_files.get(content) + if temp_file_name and os.path.isfile(temp_file_name): + return temp_file_name _, name = tempfile.mkstemp() _temp_files[content_key] = name with open(name, 'wb') as fd: