Commits

Jesse Noller committed b4964df

issue3770: if SEM_OPEN is 0, disable the mp.synchronize module, rev. Nick Coghlan, Damien Miller

Comments (0)

Files changed (5)

Doc/library/multiprocessing.rst

 leverage multiple processors on a given machine.  It runs on both Unix and
 Windows.
 
+.. warning::
+
+    This package largely requires a functioning shared semaphore
+    implementation on the host operating system to function. Without one, the 
+    :mod:`multiprocessing.synchronize` module will be disabled, and attempts to 
+    import it will result in an ImportError. See 
+    http://bugs.python.org/issue3770 for additional information.
 
 The :class:`Process` class
 ~~~~~~~~~~~~~~~~~~~~~~~~~~

Lib/multiprocessing/synchronize.py

 from multiprocessing.util import Finalize, register_after_fork, debug
 from multiprocessing.forking import assert_spawning, Popen
 
+# Try to import the mp.synchronize module cleanly, if it fails
+# raise ImportError for platforms lacking a working sem_open implementation.
+# See issue 3770
+try:
+    from _multiprocessing import SemLock
+except (ImportError):
+    raise ImportError("This platform lacks a functioning sem_open" +
+                      " implementation, therefore, the required" +
+                      " synchronization primitives needed will not" +
+                      " function, see issue 3770.")
+
 #
 # Constants
 #

Lib/test/regrtest.py

         test_tcl
         test_timeout
         test_urllibnet
+        test_multiprocessing
         """,
     'aix5':
         """
         test_ossaudiodev
         test_pep277
         test_tcl
+        test_multiprocessing
         """,
     'netbsd3':
         """
         test_ossaudiodev
         test_pep277
         test_tcl
+        test_multiprocessing
         """,
 }
 _expectations['freebsd5'] = _expectations['freebsd4']

Lib/test/test_multiprocessing.py

 import random
 import logging
 
+
+# Work around broken sem_open implementations
+try:
+    import multiprocessing.synchronize
+except ImportError, e:
+    from test.test_support import TestSkipped
+    raise TestSkipped(e)
+
 import multiprocessing.dummy
 import multiprocessing.connection
 import multiprocessing.managers
                 )
             libraries = []
 
+        elif platform.startswith('openbsd'):
+            macros = dict(                  # OpenBSD
+                HAVE_SEM_OPEN=0,            # Not implemented
+                HAVE_SEM_TIMEDWAIT=0,
+                HAVE_FD_TRANSFER=1,
+                )
+            libraries = []
+
         else:                                   # Linux and other unices
             macros = dict(
                 HAVE_SEM_OPEN=1,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.