Skip to content

Commit f01169a

Browse files
committed
Fix when cpu freq. not available
1 parent a6ba43a commit f01169a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

library/sensors/sensors_librehardwaremonitor.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,15 @@ def frequency() -> float:
124124
if sensor.SensorType == Hardware.SensorType.Clock:
125125
# Keep only real core clocks, ignore effective core clocks
126126
if "Core #" in str(sensor.Name) and "Effective" not in str(sensor.Name):
127-
frequencies.append(float(sensor.Value))
128-
# Take mean of all core clock as "CPU clock"
129-
return mean(frequencies)
127+
if sensor.Value:
128+
frequencies.append(float(sensor.Value))
129+
130+
if frequencies:
131+
# Take mean of all core clock as "CPU clock" (as it is done in Windows Task Manager Performance tab)
132+
return mean(frequencies)
133+
else:
134+
# Frequencies reading is not supported on this CPU
135+
return math.nan
130136

131137
@staticmethod
132138
def load() -> Tuple[float, float, float]: # 1 / 5 / 15min avg:
@@ -201,8 +207,8 @@ def is_available() -> bool:
201207
found_nvidia = (get_hw_and_update(Hardware.HardwareType.GpuNvidia) is not None)
202208
found_intel = (get_hw_and_update(Hardware.HardwareType.GpuIntel) is not None)
203209

204-
if found_amd and (found_nvidia or found_intel) or (found_nvidia and found_intel):
205-
logger.warning(
210+
if (found_amd and (found_nvidia or found_intel)) or (found_nvidia and found_intel):
211+
logger.info(
206212
"Found multiple GPUs on your system. Will use dedicated GPU (AMD/Nvidia) for stats if possible.")
207213

208214
return found_amd or found_nvidia or found_intel

library/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def percentage():
123123
def frequency():
124124
if THEME_DATA['STATS']['CPU']['FREQUENCY']['TEXT'].get("SHOW", False):
125125

126-
cpu_freq = f'{int(sensors.Cpu.frequency()) / 1000:.2f}'
126+
cpu_freq = f'{sensors.Cpu.frequency() / 1000:.2f}'
127127
if THEME_DATA['STATS']['CPU']['FREQUENCY']['TEXT'].get("SHOW_UNIT", True):
128128
cpu_freq += " GHz"
129129

0 commit comments

Comments
 (0)