summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2021-11-25 11:33:35 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2021-11-25 11:33:35 +0100
commita1ae994cabff37eb86c6ca4564b4f193a73a7b0d (patch)
tree8a2e164002288f5a37a668f956205b735a44699a
parent875d2195fc8efa642c7bca714d468551d1805c6c (diff)
downloadpsutil-a1ae994cabff37eb86c6ca4564b4f193a73a7b0d.tar.gz
fix #2023 [Linux] cpu_freq() return order is wrong on systems with > 9 CPUs.
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r--HISTORY.rst1
-rw-r--r--psutil/_pslinux.py7
2 files changed, 5 insertions, 3 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 139560f7..4b6ece58 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -54,6 +54,7 @@ XXXX-XX-XX
(not thread-safe).
- 1956_: [macOS] Process.cpu_times() reports incorrect timings on M1 machines.
(patch by Olivier Dormond)
+- 2023_: [Linux] cpu_freq() return order is wrong on systems with > 9 CPUs.
5.8.0
=====
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index 57925b87..1cbbec42 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -738,9 +738,10 @@ if os.path.exists("/sys/devices/system/cpu/cpufreq/policy0") or \
real-time.
"""
cpuinfo_freqs = _cpu_get_cpuinfo_freq()
- paths = sorted(
- glob.glob("/sys/devices/system/cpu/cpufreq/policy[0-9]*") or
- glob.glob("/sys/devices/system/cpu/cpu[0-9]*/cpufreq"))
+ paths = \
+ glob.glob("/sys/devices/system/cpu/cpufreq/policy[0-9]*") or \
+ glob.glob("/sys/devices/system/cpu/cpu[0-9]*/cpufreq")
+ paths.sort(key=lambda x: int(re.search(r"[0-9]+", x).group()))
ret = []
pjoin = os.path.join
for i, path in enumerate(paths):