git://git.onelab.eu
/
nepi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
systematic use of context managers for dealing with files instead of open()/close...
[nepi.git]
/
src
/
nepi
/
util
/
parallel.py
diff --git
a/src/nepi/util/parallel.py
b/src/nepi/util/parallel.py
index
3b6e281
..
bf86b57
100644
(file)
--- a/
src/nepi/util/parallel.py
+++ b/
src/nepi/util/parallel.py
@@
-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