From: Michael Tremer Date: Sun, 11 Mar 2012 13:40:11 +0000 (+0100) Subject: Change detection of number of CPU cores. X-Git-Tag: v2.1.4~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47da9ef4906e72e3e039528886350d4e53a88a73;p=oddments%2Ffireinfo.git 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. --- 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__":