diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2011-03-16 13:41:32 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2011-03-16 13:41:32 (GMT) |
commit | 0b8753d24b9a37834c23faa1da705f4ed222d928 (patch) | |
tree | 306cf9a49a0e3541408d2efda15d4d518c7d7ef9 /Lib/multiprocessing/__init__.py | |
parent | 9465d424ec2c880486514736c321f589878fa870 (diff) | |
download | cpython-0b8753d24b9a37834c23faa1da705f4ed222d928.zip cpython-0b8753d24b9a37834c23faa1da705f4ed222d928.tar.gz cpython-0b8753d24b9a37834c23faa1da705f4ed222d928.tar.bz2 |
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.
Diffstat (limited to 'Lib/multiprocessing/__init__.py')
-rw-r--r-- | Lib/multiprocessing/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py index 28a5eec..fdd012e 100644 --- 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' + if sys.platform == 'darwin': + comm = '/usr' + comm try: - with os.popen('sysctl -n hw.ncpu') as p: + with os.popen(comm) as p: num = int(p.read()) except ValueError: num = 0 |