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

This commit is contained in:
J. Nick Koston authored and GitHub committed 2025-02-19 06:10:33 +13:00
1 parent 1257640e48
commit abbd72e802
4 files changed
+40 -13

No files matched your search

+11
View File
@@ -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()
)