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 (#8268)
This commit is contained in:
@@ -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()
|
||||
)
|
||||
|
Reference in New Issue
Block a user