From 47da9ef4906e72e3e039528886350d4e53a88a73 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 11 Mar 2012 14:40:11 +0100 Subject: [PATCH] Change detection of number of CPU cores. Recently, /sys/class/cpuid was read to find out how many CPUs were running in the system. It did not work on the experimental OMAP kernel, so we change it to a POSIX implementation that returns the number of all online CPUs. --- fireinfo/cpu.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fireinfo/cpu.py b/fireinfo/cpu.py index 9199df9..32d885d 100644 --- a/fireinfo/cpu.py +++ b/fireinfo/cpu.py @@ -19,12 +19,11 @@ # # ############################################################################### -import os.path +import os import system PROC_CPUINFO = "/proc/cpuinfo" -SYS_CLASS_CPUID = "/sys/class/cpuid/cpu%d" class CPU(object): """ @@ -178,11 +177,7 @@ class CPU(object): """ Count number of CPUs (cores). """ - i = 0 - while (os.path.exists(SYS_CLASS_CPUID % i)): - i += 1 - - return i or 1 + return os.sysconf("SC_NPROCESSORS_ONLN") if __name__ == "__main__": -- 2.39.2