[Kimchi-devel] [kimchi-devel][PATCH 1/7] Fix md5 file handler leak

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Tue Jan 20 08:45:04 UTC 2015


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

md5 file open without close, fix by closing it in with clause.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/model/debugreports.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/model/debugreports.py b/src/kimchi/model/debugreports.py
index fbc0463..222270d 100644
--- a/src/kimchi/model/debugreports.py
+++ b/src/kimchi/model/debugreports.py
@@ -112,8 +112,9 @@ class DebugReportsModel(object):
             # Deleting md5
             msg = 'Deleting report md5 file: "%s"' % (md5_report_file)
             kimchi_log.info(msg)
-            md5 = open(md5_report_file).read().strip()
-            kimchi_log.info('Md5 file content: "%s"', md5)
+            with open(md5_report_file) as f:
+                md5 = f.read().strip()
+                kimchi_log.info('Md5 file content: "%s"', md5)
             os.remove(md5_report_file)
             cb('OK', True)
             return
-- 
1.9.3




More information about the Kimchi-devel mailing list