[Python-checkins] cpython (2.7): Issue #11569: use absolute path to the sysctl command in multiprocessing to

ronald.oussoren python-checkins at python.org
Wed Mar 16 14:48:02 CET 2011


http://hg.python.org/cpython/rev/b8f280d0cdbf
changeset:   68596:b8f280d0cdbf
branch:      2.7
parent:      68589:b3e07abeff45
user:        Ronald Oussoren <ronaldoussoren at mac.com>
date:        Wed Mar 16 09:47:15 2011 -0400
summary:
  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.

files:
  Lib/multiprocessing/__init__.py
  Misc/ACKS
  Misc/NEWS

diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py
--- a/Lib/multiprocessing/__init__.py
+++ b/Lib/multiprocessing/__init__.py
@@ -116,8 +116,11 @@
         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
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -587,6 +587,7 @@
 Joe Norton
 Neal Norwitz
 Michal Nowikowski
+Steffen Daode Nurpmeso
 Nigel O'Brian
 Kevin O'Connor
 Tim O'Malley
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,10 @@
 Library
 -------
 
+- 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.
+
 - Issue #11500: Fixed a bug in the os x proxy bypass code for fully qualified 
   IP addresses in the proxy exception list. 
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list