1
0
mirror of https://github.com/esphome/esphome.git synced 2025-07-22 23:09:37 +01:00

Use the process CPU count to determine how many children to create ()

This commit is contained in:
J. Nick Koston
2025-02-18 11:10:33 -06:00
committed by GitHub
parent 1257640e48
commit abbd72e802
4 changed files with 40 additions and 13 deletions

@@ -188,3 +188,14 @@ def get_binary(name: str, version: str) -> str:
"""
)
raise
def get_usable_cpu_count() -> int:
"""Return the number of CPUs that can be used for processes.
On Python 3.13+ this is the number of CPUs that can be used for processes.
On older Python versions this is the number of CPUs.
"""
return (
os.process_cpu_count() if hasattr(os, "process_cpu_count") else os.cpu_count()
)