File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff 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 ]
You can’t perform that action at this time.
0 commit comments