diff options
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r-- | numpy/testing/_private/utils.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 1b88d91f6..8b098f1d1 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -192,9 +192,8 @@ elif sys.platform[:5] == 'linux': """ try: - f = open(_proc_pid_stat, 'r') - l = f.readline().split(' ') - f.close() + with open(_proc_pid_stat, 'r') as f: + l = f.readline().split(' ') return int(l[22]) except Exception: return @@ -221,9 +220,8 @@ if sys.platform[:5] == 'linux': if not _load_time: _load_time.append(time.time()) try: - f = open(_proc_pid_stat, 'r') - l = f.readline().split(' ') - f.close() + with open(_proc_pid_stat, 'r') as f: + l = f.readline().split(' ') return int(l[13]) except Exception: return int(100*(time.time()-_load_time[0])) |