Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2439 fix for thermal zones #2440

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -835,3 +835,7 @@ I: 2272
N: Sam Gross
W: https://github.com/colesbury
I: 2401, 2427

N: Siena Richard
W: https://github.com/siena-sam
I: 2439
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ XXXX-XX-XX

- 2427_: psutil (segfault) on import in the free-threaded (no GIL) version of
Python 3.13. (patch by Sam Gross)
- 2439_: correct sensors_temperatures calculation for theraml_zone (patch by
Siena Richard)

6.0.0
======
Expand Down
16 changes: 10 additions & 6 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,23 +1467,27 @@ def sensors_temperatures():
for trip_point in trip_points:
path = os.path.join(base, trip_point + "_type")
trip_type = cat(path, fallback='').strip()
current_critical = None
current_high = None
if trip_type == 'critical':
critical = bcat(
current_critical = bcat(
os.path.join(base, trip_point + "_temp"), fallback=None
)
elif trip_type == 'high':
high = bcat(
current_high = bcat(
os.path.join(base, trip_point + "_temp"), fallback=None
)

if high is not None:
if current_high is not None:
try:
high = float(high) / 1000.0
current_high = float(current_high) / 1000.0
high = max(high, current_high) if high else current_high
except ValueError:
high = None
if critical is not None:
if current_critical is not None:
try:
critical = float(critical) / 1000.0
current_critical = float(current_critical) / 1000.0
critical = max(critical, current_critical) if critical else current_critical
except ValueError:
critical = None

Expand Down
2 changes: 2 additions & 0 deletions psutil/tests/test_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,8 @@ def glob_mock(path):
return [
'/sys/class/thermal/thermal_zone1/trip_point_0_type',
'/sys/class/thermal/thermal_zone1/trip_point_0_temp',
'/sys/class/thermal/thermal_zone1/trip_point_1_type',
'/sys/class/thermal/thermal_zone1/trip_point_1_temp',
]
return []

Expand Down