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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Use "with" with open
- Add a module docstring

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

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):
-- 
2.36.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux