We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ResourceWarning: unclosed file
test_cpudemo
1 parent 56a94b5 commit ae68a02Copy full SHA for ae68a02
qwt/tests/test_cpudemo.py
@@ -202,10 +202,11 @@ def upTime(self):
202
203
def __lookup(self):
204
if os.path.exists("/proc/stat"):
205
- for line in open("/proc/stat"):
206
- words = line.split()
207
- if words[0] == "cpu" and len(words) >= 5:
208
- return [float(w) for w in words[1:]]
+ with open("/proc/stat") as file:
+ for line in file:
+ words = line.split()
+ if words[0] == "cpu" and len(words) >= 5:
209
+ return [float(w) for w in words[1:]]
210
else:
211
result = CpuStat.dummyValues[CpuStat.counter]
212
CpuStat.counter += 1
0 commit comments