summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/multiprocessing.rst7
-rw-r--r--Lib/multiprocessing/synchronize.py11
-rwxr-xr-xLib/test/regrtest.py3
-rw-r--r--Lib/test/test_multiprocessing.py8
-rw-r--r--setup.py8
5 files changed, 37 insertions, 0 deletions
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index 42d76a3..a005dc4 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py
index 428656a..dacf45a 100644
--- a/Lib/multiprocessing/synchronize.py
+++ b/Lib/multiprocessing/synchronize.py
@@ -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
#
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index f185111..996395b 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -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']
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 214a420..b0746e9 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -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
diff --git a/setup.py b/setup.py
index f979a29..4b23186 100644
--- 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,