diff options
author | Victor Stinner <vstinner@python.org> | 2023-10-01 01:14:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-01 01:14:57 (GMT) |
commit | a46e96076898d126c9f276aef1934195aac34b4e (patch) | |
tree | beaec25a75f381f77b74bf4e164eb813c20ec81f /Lib/concurrent | |
parent | 53eb9a676f8c59b206dfc536b7590f6563ad65e0 (diff) | |
download | cpython-a46e96076898d126c9f276aef1934195aac34b4e.zip cpython-a46e96076898d126c9f276aef1934195aac34b4e.tar.gz cpython-a46e96076898d126c9f276aef1934195aac34b4e.tar.bz2 |
gh-109649: Use os.process_cpu_count() (#110165)
Replace os.cpu_count() with os.process_cpu_count() in modules:
* compileall
* concurrent.futures
* multiprocessing
Replace os.cpu_count() with os.process_cpu_count() in programs:
* _decimal deccheck.py test
* freeze.py
* multissltests.py
* python -m test (regrtest)
* wasm_build.py
Other changes:
* test.pythoninfo logs os.process_cpu_count().
* regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
Diffstat (limited to 'Lib/concurrent')
-rw-r--r-- | Lib/concurrent/futures/process.py | 2 | ||||
-rw-r--r-- | Lib/concurrent/futures/thread.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 3990e6b..ffaffdb 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -666,7 +666,7 @@ class ProcessPoolExecutor(_base.Executor): _check_system_limits() if max_workers is None: - self._max_workers = os.cpu_count() or 1 + self._max_workers = os.process_cpu_count() or 1 if sys.platform == 'win32': self._max_workers = min(_MAX_WINDOWS_WORKERS, self._max_workers) diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py index 3b3a36a..a024033 100644 --- a/Lib/concurrent/futures/thread.py +++ b/Lib/concurrent/futures/thread.py @@ -139,10 +139,10 @@ class ThreadPoolExecutor(_base.Executor): # * CPU bound task which releases GIL # * I/O bound task (which releases GIL, of course) # - # We use cpu_count + 4 for both types of tasks. + # We use process_cpu_count + 4 for both types of tasks. # But we limit it to 32 to avoid consuming surprisingly large resource # on many core machine. - max_workers = min(32, (os.cpu_count() or 1) + 4) + max_workers = min(32, (os.process_cpu_count() or 1) + 4) if max_workers <= 0: raise ValueError("max_workers must be greater than 0") |