cpython: c394f2d42ff8 (original) (raw)
Mercurial > cpython
changeset 68593:c394f2d42ff8 3.1
Issue #11569: use absolute path to the sysctl command in multiprocessing to ensure that it will be found regardless of the shell PATH. This ensures that multiprocessing.cpu_count works on default installs of MacOSX. [#11569]
Ronald Oussoren ronaldoussoren@mac.com | |
---|---|
date | Wed, 16 Mar 2011 09:41:32 -0400 |
parents | f2ac5bbc1623 |
children | 02dbfceeee55 d108a7dff2a0 |
files | Lib/multiprocessing/__init__.py Misc/ACKS Misc/NEWS |
diffstat | 3 files changed, 9 insertions(+), 1 deletions(-)[+] [-] Lib/multiprocessing/__init__.py 5 Misc/ACKS 1 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/multiprocessing/init.py +++ b/Lib/multiprocessing/init.py @@ -115,8 +115,11 @@ def cpu_count(): except (ValueError, KeyError): num = 0 elif 'bsd' in sys.platform or sys.platform == 'darwin':
comm = '/sbin/sysctl -n hw.ncpu'[](#l1.7)
if sys.platform == 'darwin':[](#l1.8)
comm = '/usr' + comm[](#l1.9) try:[](#l1.10)
with os.popen('sysctl -n hw.ncpu') as p:[](#l1.11)
with os.popen(comm) as p:[](#l1.12) num = int(p.read())[](#l1.13) except ValueError:[](#l1.14) num = 0[](#l1.15)
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -583,6 +583,7 @@ Tim Northover Joe Norton Neal Norwitz Michal Nowikowski +Steffen Daode Nurpmeso Nigel O'Brian Kevin O'Connor Tim O'Malley
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -40,6 +40,10 @@ Core and Builtins Library ------- +- Issue #11569: use absolute path to the sysctl command in multiprocessing to