]> granicus.if.org Git - python/commitdiff
Issue #11569: use absolute path to the sysctl command in multiprocessing to
authorRonald Oussoren <ronaldoussoren@mac.com>
Wed, 16 Mar 2011 13:47:15 +0000 (09:47 -0400)
committerRonald Oussoren <ronaldoussoren@mac.com>
Wed, 16 Mar 2011 13:47:15 +0000 (09:47 -0400)
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.

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

index 4e1b6aedd108818aea1b34566390f20e6bc1bc18..4963293bd9fa714913b6f5bf372ce1fedd812616 100644 (file)
@@ -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
index a1f620f924e8aa838f08b3f359e7d33e67533f6f..5d617daa36d287e76a29734f9ddbbbe92607881f 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -587,6 +587,7 @@ Tim Northover
 Joe Norton
 Neal Norwitz
 Michal Nowikowski
+Steffen Daode Nurpmeso
 Nigel O'Brian
 Kevin O'Connor
 Tim O'Malley
index af1ba7f4fc73c9cb0ec533e75228a6be98314096..0c5b7f2631f3dcff939b4f951b6d85215efac0a7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,10 @@ Core and Builtins
 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.