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.
# #
###############################################################################
-import os.path
+import os
import system
PROC_CPUINFO = "/proc/cpuinfo"
-SYS_CLASS_CPUID = "/sys/class/cpuid/cpu%d"
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__":