X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Futil%2Fparallel.py;h=bf86b57435dfaa840b15c86ae9c3bc397b1cc441;hb=cb5d027b813a27d7de263653e1a8e0cef5490f0a;hp=b7caeac3fbb79f6118fbca8249a220437071599c;hpb=99d8b2a4431d8fafd0385e189375106d46f1abd9;p=nepi.git diff --git a/src/nepi/util/parallel.py b/src/nepi/util/parallel.py index b7caeac3..bf86b574 100644 --- a/src/nepi/util/parallel.py +++ b/src/nepi/util/parallel.py @@ -3,9 +3,8 @@ # Copyright (C) 2013 INRIA # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -85,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