Skip to content

Commit

Permalink
1129: have sensors_temperatures() on Linux skip entry on IOError
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Sep 27, 2017
1 parent 12109ee commit 943367f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ XXXX-XX-XX

*Bug fixes*

- 1129_: [Linux] sensors_temperatures() may crash with IOError.
- 1131_: [SunOS] fix compilation warnings. (patch by Arnon Yaari)
- 1138_: [Linux] can't compile on CentOS 5.0 and RedHat 5.0.
(patch by Prodesire)
Expand Down
21 changes: 11 additions & 10 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,21 +1142,22 @@ def sensors_temperatures():
basenames = sorted(set([x.split('_')[0] for x in basenames]))

for base in basenames:
try:
current = float(cat(base + '_input')) / 1000.0
except (IOError, OSError) as err:
# A lot of things can go wrong here, so let's just skip the
# whole entry.
# https://github.com/giampaolo/psutil/issues/1009
# https://github.com/giampaolo/psutil/issues/1101
# https://github.com/giampaolo/psutil/issues/1129
warnings.warn("ignoring %r" % err, RuntimeWarning)
continue

unit_name = cat(os.path.join(os.path.dirname(base), 'name'),
binary=False)
high = cat(base + '_max', fallback=None)
critical = cat(base + '_crit', fallback=None)
label = cat(base + '_label', fallback='', binary=False)
try:
current = float(cat(base + '_input')) / 1000.0
except OSError as err:
# https://github.com/giampaolo/psutil/issues/1009
# https://github.com/giampaolo/psutil/issues/1101
if err.errno in (errno.EIO, errno.ENODEV):
warnings.warn("ignoring %r" % err, RuntimeWarning)
continue
else:
raise

if high is not None:
high = float(high) / 1000.0
Expand Down

0 comments on commit 943367f

Please sign in to comment.