()
| 1090 | |
| 1091 | @staticmethod |
| 1092 | def GetCPUCoresRange(): |
| 1093 | try: |
| 1094 | with open('/sys/devices/system/cpu/present', 'r') as f: |
| 1095 | indexes = f.readline() |
| 1096 | r = list(map(int, indexes.split('-'))) |
| 1097 | if len(r) == 1: |
| 1098 | return list(range(r[0], r[0] + 1)) |
| 1099 | return list(range(r[0], r[1] + 1)) |
| 1100 | except Exception: |
| 1101 | logging.exception('Failed to retrieve number of CPUs.') |
| 1102 | raise |
| 1103 | |
| 1104 | @staticmethod |
| 1105 | def GetCPUPathForId(cpu_index): |