]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
issue3770: if SEM_OPEN is 0, disable the mp.synchronize module, rev. Nick Coghlan...
authorJesse Noller <jnoller@gmail.com>
Tue, 30 Sep 2008 00:15:45 +0000 (00:15 +0000)
committerJesse Noller <jnoller@gmail.com>
Tue, 30 Sep 2008 00:15:45 +0000 (00:15 +0000)
Doc/library/multiprocessing.rst
Lib/multiprocessing/synchronize.py
Lib/test/regrtest.py
Lib/test/test_multiprocessing.py
setup.py

index 42d76a3ed83a6b4be28830d190c0a44421e361ed..a005dc40119584603dd5b2c760d0372a79ca9323 100644 (file)
@@ -18,6 +18,13 @@ to this, the :mod:`multiprocessing` module allows the programmer to fully
 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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
index 428656a5b15d5c8f35e66409672144fc4331acb3..dacf45acca71dc0a3cac8c97881ff5dda6c0b5e1 100644 (file)
@@ -21,6 +21,17 @@ from multiprocessing.process import current_process
 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
 #
index f185111fc36824b6ab6e12367ab3b95547bb1516..996395bb8e3de8550e80bfcf2ca53323f01c5eee 100755 (executable)
@@ -1047,6 +1047,7 @@ _expectations = {
         test_tcl
         test_timeout
         test_urllibnet
+        test_multiprocessing
         """,
     'aix5':
         """
@@ -1077,6 +1078,7 @@ _expectations = {
         test_ossaudiodev
         test_pep277
         test_tcl
+        test_multiprocessing
         """,
     'netbsd3':
         """
@@ -1092,6 +1094,7 @@ _expectations = {
         test_ossaudiodev
         test_pep277
         test_tcl
+        test_multiprocessing
         """,
 }
 _expectations['freebsd5'] = _expectations['freebsd4']
index 214a420708bc35b20c735e6ea42111d43ed6615f..b0746e9f3b5dd9e6da3937e8ce4e678c9e93bfd7 100644 (file)
@@ -18,6 +18,14 @@ import socket
 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
index f979a2914389634faa185edbd19f448772308e1a..4b2318658c6c01fa76905d3e88d1360429cd0e78 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1269,6 +1269,14 @@ class PyBuildExt(build_ext):
                 )
             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,