<commit_before>import math
import multiprocessing

from conans.util.files import load


def build_jobs(conanfile):
    njobs = conanfile.conf.get("tools.build:jobs",
                               default=_cpu_count(),
                               check_type=int)
    return njobs


def _cpu_count():
    try:
        try:
            # This is necessary to deduce docker cpu_count
            cfs_quota_us = int(load("/sys/fs/cgroup/cpu/cpu.cfs_quota_us"))
            cfs_period_us = int(load("/sys/fs/cgroup/cpu/cpu.cfs_period_us"))
            if cfs_quota_us > 0 and cfs_period_us > 0:
                return int(math.ceil(cfs_quota_us / cfs_period_us))
        except (EnvironmentError, TypeError):
            pass
        return multiprocessing.cpu_count()
    except NotImplementedError:
        # print("multiprocessing.cpu_count() not implemented. Defaulting to 1 cpu")
        return 1  # Safe guess<commit_msg>[bug] get_cpus is not supporting cgroup2 #11635 (#11667)<commit_after>import math
import multiprocessing
import os

from conans.util.files import load


def build_jobs(conanfile):
    njobs = conanfile.conf.get("tools.build:jobs",
                               default=_cpu_count(),
                               check_type=int)
    return njobs


def _cpu_count():
    try:
        try:
            # This is necessary to deduce docker cpu_count
            cfs_quota_us = cfs_period_us = 0
            # cgroup2
            if os.path.exists("/sys/fs/cgroup/cgroup.controllers"):
                cpu_max = load("/sys/fs/cgroup/cpu.max").split()
                if cpu_max[0] != "max":
                    if len(cpu_max) == 1:
                        cfs_quota_us, cfs_period_us = int(cpu_max[0]), 100_000
                    else:
                        cfs_quota_us, cfs_period_us = map(int, cpu_max)
            else:  # cgroup1
                cfs_quota_us = int(load("/sys/fs/cgroup/cpu/cpu.cfs_quota_us"))
                cfs_period_us = int(load("/sys/fs/cgroup/cpu/cpu.cfs_period_us"))
            if cfs_quota_us > 0 and cfs_period_us > 0:
                return int(math.ceil(cfs_quota_us / cfs_period_us))
        except (EnvironmentError, TypeError):
            pass
        return multiprocessing.cpu_count()
    except NotImplementedError:
        # print("multiprocessing.cpu_count() not implemented. Defaulting to 1 cpu")
        return 1  # Safe guess
{'fraction_non_alphanumeric': 0.09378907878282618, 'fraction_numerical': 0.012922050854522717, 'mean_word_length': 1.9556650246305418, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5736405', 'n_tokens_mistral': 789, 'n_tokens_neox': 745, 'n_words': 151}