Skip to content

Commit 3dcf2fd

Browse files
committed
Ensure all core indices are handled, RPI 4 support
1 parent 9a935eb commit 3dcf2fd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

auto_cpufreq/core.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,10 +1135,20 @@ def sysinfo():
11351135
cpu_core = dict()
11361136
freq_per_cpu = []
11371137
for i in range(0, len(coreid_info), 3):
1138-
freq_per_cpu.append(float(coreid_info[i + 1].split(":")[-1]))
1138+
# ensure that indices are within the valid range, before accessing the corresponding elements
1139+
if i + 1 < len(coreid_info):
1140+
freq_per_cpu.append(float(coreid_info[i + 1].split(":")[-1]))
1141+
else:
1142+
# handle the case where the index is out of range
1143+
continue
1144+
# ensure that indices are within the valid range, before accessing the corresponding elements
11391145
cpu = int(coreid_info[i].split(":")[-1])
1140-
core = int(coreid_info[i + 2].split(":")[-1])
1141-
cpu_core[cpu] = core
1146+
if i + 2 < len(coreid_info):
1147+
core = int(coreid_info[i + 2].split(":")[-1])
1148+
cpu_core[cpu] = core
1149+
else:
1150+
# handle the case where the index is out of range
1151+
continue
11421152

11431153
online_cpu_count = len(cpu_core)
11441154
offline_cpus = [str(cpu) for cpu in range(total_cpu_count) if cpu not in cpu_core]

0 commit comments

Comments
 (0)