From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Proc uptime file opened without close,
close it in with clause.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/model/host.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index dff89cb..7f2ccdc 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -167,8 +167,9 @@ class HostStatsModel(object):
# FIXME when we upgrade psutil, we can get uptime by psutil.uptime
# we get uptime by float(open("/proc/uptime").readline().split()[0])
# and calculate the first io_rate after the OS started.
- seconds = (timestamp - preTimeStamp if preTimeStamp else
- float(open("/proc/uptime").readline().split()[0]))
+ with open("/proc/uptime") as time_f:
+ seconds = (timestamp - preTimeStamp if preTimeStamp else
+ float(time_f.readline().split()[0]))
self.host_stats['timestamp'] = timestamp
self._get_host_disk_io_rate(seconds)
--
1.9.3