diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2011-03-16 09:47:15 -0400 |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2011-03-16 09:47:15 -0400 |
commit | 1a5b7aceb8fd8d17df69f802f947f45659dcb0fd (patch) | |
tree | a2c3bd7dbfdd615d720dd9deeb00638ebb4501e6 /Lib/multiprocessing/__init__.py | |
parent | c811d10c2f5c824e434e2994ddb2a7c7a9da28a8 (diff) | |
download | cpython-1a5b7aceb8fd8d17df69f802f947f45659dcb0fd.tar.gz |
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.
Patch by Steffen Daode Nurpmeso.
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 4e1b6aedd1..4963293bd9 100644 --- a/Lib/multiprocessing/__init__.py +++ b/Lib/multiprocessing/__init__.py @@ -116,8 +116,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 |