Skip to content

Commit

Permalink
fix #1004 / linux / Process.io_counters(): fix possible ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Apr 5, 2017
1 parent 9009349 commit feeb713
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
**Bug fixes**

- 1000_: fixed some setup.py warnings.
- 1002_: remove C macro which will not be available on new Solaris versions.
(patch by Danek Duvall)
- 1002_: [SunOS] remove C macro which will not be available on new Solaris
versions. (patch by Danek Duvall)
- 1004_: [Linux] Process.io_counters() may raise ValueError.

*2017-03-24*

Expand All @@ -18,12 +19,12 @@

**Bug fixes**

- 996_: [Linux] sensors_temperatures() may not show all temperatures.
- 997_: [FreeBSD] virtual_memory() may fail due to missing sysctl parameter on
FreeBSD 12.
- 981_: [Linux] cpu_freq() may return an empty list.
- 993_: [Windows] Process.memory_maps() on Python 3 may raise
UnicodeDecodeError.
- 996_: [Linux] sensors_temperatures() may not show all temperatures.
- 997_: [FreeBSD] virtual_memory() may fail due to missing sysctl parameter on
FreeBSD 12.

*2017-03-05*

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Summary

psutil (process and system utilities) is a cross-platform library for
retrieving information on **running processes** and **system utilization**
(CPU, memory, disks, networkm sensors) in Python.
(CPU, memory, disks, network, sensors) in Python.
It is useful mainly for **system monitoring**, **profiling and limiting process
resources** and **management of running processes**.
It implements many functionalities offered by command line tools such as:
Expand Down
9 changes: 7 additions & 2 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,13 @@ def io_counters(self):
fields = {}
with open_binary(fname) as f:
for line in f:
name, value = line.split(b': ')
fields[name] = int(value)
# https://github.com/giampaolo/psutil/issues/1004
line = line.strip()
if line:
name, value = line.split(b': ')
fields[name] = int(value)
if not fields:
raise RuntimeError("%s file was empty" % fname)
return pio(
fields[b'syscr'], # read syscalls
fields[b'syscw'], # write syscalls
Expand Down

0 comments on commit feeb713

Please sign in to comment.