systematic use of context managers for dealing with files instead of open()/close...
[nepi.git] / src / nepi / util / parallel.py
index 3b6e281..bf86b57 100644 (file)
@@ -84,11 +84,8 @@ class ParallelRun(object):
         if maxthreads is None:
             if N_PROCS is None:
                 try:
-                    f = open("/proc/cpuinfo")
-                    try:
+                    with open("/proc/cpuinfo") as f:
                         N_PROCS = sum("processor" in l for l in f)
-                    finally:
-                        f.close()
                 except:
                     pass
             maxthreads = N_PROCS