summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tiptop/__about__.py2
-rw-r--r--src/tiptop/_cpu.py22
2 files changed, 12 insertions, 12 deletions
diff --git a/src/tiptop/__about__.py b/src/tiptop/__about__.py
index b5fdc75..d31c31e 100644
--- a/src/tiptop/__about__.py
+++ b/src/tiptop/__about__.py
@@ -1 +1 @@
-__version__ = "0.2.2"
+__version__ = "0.2.3"
diff --git a/src/tiptop/_cpu.py b/src/tiptop/_cpu.py
index e217f95..26d5085 100644
--- a/src/tiptop/_cpu.py
+++ b/src/tiptop/_cpu.py
@@ -98,21 +98,21 @@ def get_current_freq():
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
]
for candidate in candidates:
- file = Path(candidate)
- if file.exists():
- with open(file) as f:
+ if Path(candidate).exists():
+ with open(candidate) as f:
content = f.read()
return int(content) / 1000
- c = psutil.cpu_freq()
- if hasattr(c, "current"):
- cpu_freq = c.current
- if psutil.__version__ == "5.9.0" and cpu_freq < 10:
- # Work around <https://github.com/giampaolo/psutil/issues/2049>
- cpu_freq *= 1000
- return cpu_freq
+ try:
+ cpu_freq = psutil.cpu_freq().current
+ except Exception:
+ # https://github.com/nschloe/tiptop/issues/25#issuecomment-1061390966
+ return None
- return None
+ if psutil.__version__ == "5.9.0" and cpu_freq < 10:
+ # Work around <https://github.com/giampaolo/psutil/issues/2049>
+ cpu_freq *= 1000
+ return cpu_freq
class CPU(Widget):