diff mbox series

[4/7] rteval: cyclictest.py: Use "with" with resource allocation

Message ID 20220603161224.10947-4-jkacur@redhat.com
State New
Headers show
Series [1/7] rteval: rteval-cmd: Use "with" with open | expand

Commit Message

John Kacur June 3, 2022, 4:12 p.m. UTC
- Use "with" with open
- Add a module docstring

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval/modules/measurement/cyclictest.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py
index 8fdd5341794a..4c8d510c4a34 100644
--- a/rteval/modules/measurement/cyclictest.py
+++ b/rteval/modules/measurement/cyclictest.py
@@ -24,6 +24,7 @@ 
 #   including keys needed to generate an equivalently functional executable
 #   are deemed to be part of the source code.
 #
+""" cyclictest.py - object to manage a cyclictest executable instance """
 
 import os
 import subprocess
@@ -254,14 +255,13 @@  class Cyclictest(rtevalModulePrototype):
     @staticmethod
     def __get_debugfs_mount():
         ret = None
-        mounts = open('/proc/mounts')
-        for l in mounts:
-            field = l.split()
-            if field[2] == "debugfs":
-                ret = field[1]
-                break
-        mounts.close()
-        return ret
+        with open('/proc/mounts') as mounts:
+            for l in mounts:
+                field = l.split()
+                if field[2] == "debugfs":
+                    ret = field[1]
+                    break
+            return ret
 
 
     def _WorkloadSetup(self):