Source code for ramble.util.cpus

# Copyright 2022-2026 The Ramble Authors
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

import os


[docs] def cpus_available() -> int: if hasattr(os, "sched_getaffinity"): return len(os.sched_getaffinity(0)) return os.cpu_count() or 1