kolibri/utils/pskolibri/_pslinux.py
def cpu_count_logical():
    """Return the number of logical CPUs in the system."""
    try:
        return os.sysconf("SC_NPROCESSORS_ONLN")
    except ValueError:
        # as a second fallback we try to parse /proc/cpuinfo
        num = 0
        with open_binary("%s/cpuinfo" % get_procfs_path()) as f:
            for line in f:
                if line.lower().startswith(b"processor"):
                    num += 1

        # unknown format (e.g. amrel/sparc architectures), see:
        # https://github.com/giampaolo/psutil/issues/200
        # try to parse /proc/stat as a last resort
        if num == 0:
            search = re.compile(r"cpu\d")
            with open_text("%s/stat" % get_procfs_path()) as f:
                for line in f:
                    line = line.split(" ")[0]
                    if search.match(line):
                        num += 1

        if num == 0:
            # mimic os.cpu_count()
            return None
        return num
Return the number of logical CPUs in the system.
Return the number of logical CPUs in the system.
Return the number of logical CPUs in the system .
def cpu_count_logical():
    try:
        return os.sysconf("SC_NPROCESSORS_ONLN")
    except ValueError:
        num = 0
        with open_binary("%s/cpuinfo" % get_procfs_path()) as f:
            for line in f:
                if line.lower().startswith(b"processor"):
                    num += 1
        if num == 0:
            search = re.compile(r"cpu\d")
            with open_text("%s/stat" % get_procfs_path()) as f:
                for line in f:
                    line = line.split(" ")[0]
                    if search.match(line):
                        num += 1
        if num == 0:
            return None
        return num
def cpu_count_logical ( ) : try : return os . sysconf ( "SC_NPROCESSORS_ONLN" ) except ValueError : num = 0 with open_binary ( "%s/cpuinfo" % get_procfs_path ( ) ) as f : for line in f : if line . lower ( ) . startswith ( b"processor" ) : num += 1 if num == 0 : search = re . compile ( r"cpu\d" ) with open_text ( "%s/stat" % get_procfs_path ( ) ) as f : for line in f : line = line . split ( " " ) [ 0 ] if search . match ( line ) : num += 1 if num == 0 : return None return num
Return the number of logical CPUs in the system.
Return the number of logical CPUs in the system .
"""Return the number of logical CPUs in the system.""" # as a second fallback we try to parse /proc/cpuinfo # unknown format (e.g. amrel/sparc architectures), see: # https://github.com/giampaolo/psutil/issues/200 # try to parse /proc/stat as a last resort # mimic os.cpu_count()