]> 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:41:32 +0000 (09:41 -0400)
committerRonald Oussoren <ronaldoussoren@mac.com>
Wed, 16 Mar 2011 13:41:32 +0000 (09:41 -0400)
ensure that it will be found regardless of the shell PATH. This ensures
that multiprocessing.cpu_count works on default installs of MacOSX.

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

index 28a5eecffd71c5f30215335b5220dfdb5a2c455c..fdd012ea4ee1c0b36dddbb98f94c1571cee950c8 100644 (file)
@@ -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
index c7fd2ff9a037aac1bb2fd3d2b0a984a1498c462a..e5ee8710b0087762d456941bfe50ebd06d4bd807 100644 (file)
--- 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
index c4627fac66ace8d960b87fa05c26cbc8b9662983..d5c4699b68ec4268f2a272cc6af670f7bb22d01f 100644 (file)
--- 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
+  ensure that it will be found regardless of the shell PATH. This ensures
+  that multiprocessing.cpu_count works on default installs of MacOSX.
+
 - Issue #11501: disutils.archive_utils.make_zipfile no longer fails if zlib is
   not installed. Instead, the zipfile.ZIP_STORED compression is used to create
   the ZipFile. Patch by Natalia B. Bidart.