Skip to content

cgroup

CPU quota of the cgroup of the process.

A container limits its CPUs by a quota of its cgroup, which os.process_cpu_count() does not see: it counts the CPUs of the host. available_cpus is the number of processes a run may use. This module imports only the standard library.

cpu_quota

cpu_quota(root=CGROUP_ROOT, proc_cgroup=PROC_CGROUP)

Get the CPU quota of the cgroup of the process.

Parameters:

Name Type Description Default
root Path

the mount of the cgroup file system.

CGROUP_ROOT
proc_cgroup Path

the file with the cgroup of the process.

PROC_CGROUP

Returns:

Type Description
int | None

The floor of the smallest quota of the cgroup and its parents (cgroup v2) or of its quota (v1), at least 1, None without a quota. A quota is max (v2) or -1 (v1) without a limit; a file which is no quota, e.g. garbage, a value which is no finite positive number or a directory, sets no quota.

available_cpus

available_cpus()

Get the number of CPUs a run may use: the CPUs of the process bounded by the quota of its cgroup, at least 1.