This document describes the current stable version of Celery (5.7). For development docs, go here.

celery.utils.sysinfo

System information utilities.

celery.utils.sysinfo.AUTO_CONCURRENCY = 'auto'

Sentinel string accepted by worker_concurrency / --concurrency to request cgroup-aware auto-sizing on Linux.

class celery.utils.sysinfo.CpuBudget(count: int, available: int, quota: float | None)[source]

Result of cpu_budget().

available: int

Affinity-aware CPU count, see available_cpu_count().

count: int

Concurrency to use.

quota: float | None

cgroup CFS quota in CPUs, or None when no quota applies or the quota was not consulted.

celery.utils.sysinfo.available_cpu_count() → int[source]

Return the number of CPUs this process may run on.

Honors the scheduler affinity mask (taskset, cpusets, docker run --cpuset-cpus) via os.process_cpu_count() on Python 3.13+ or os.sched_getaffinity() on older Linux. Falls back to os.cpu_count() (or 2 if undetermined) where neither is available.

celery.utils.sysinfo.cgroup_cpu_quota() → float | None[source]

Return the CFS CPU quota (in CPUs) that applies to this process.

Walks from the process’s own cgroup (/proc/self/cgroup, or the mount root when unreadable) up to the root and returns the minimum quota, trying cgroup v2 then v1. None when no quota applies.

celery.utils.sysinfo.cpu_budget(use_cgroup_quota: bool = True) → CpuBudget[source]

Return the CPU budget for sizing a worker pool.

Starts from available_cpu_count(). When use_cgroup_quota is True (CPU-bound pools), caps it to ceil(quota) of any cgroup CFS quota, clamped to [1, available]. ceil follows joblib/loky so a fractional quota is fully used; see worker_concurrency.

class celery.utils.sysinfo.df(path: str | bytes | PathLike)[source]

Disk information.

property available: float
property capacity: int
property stat: statvfs_result
property total_blocks: float
celery.utils.sysinfo.is_auto_concurrency(value) → bool[source]

Return True if value is the auto concurrency sentinel.

Accepts case-insensitive "auto" with surrounding whitespace stripped.

celery.utils.sysinfo.load_average() → tuple[float, ...][source]

Return system load average as a triple.