[Python-checkins] cpython (3.4): Issue #23400: Raise same exception on both Python 2 and 3 if sem_open is not

berker.peksag python-checkins at python.org
Wed Apr 8 16:57:30 CEST 2015


https://hg.python.org/cpython/rev/749fd043de95
changeset:   95486:749fd043de95
branch:      3.4
parent:      95483:2b62f8954566
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Wed Apr 08 17:56:30 2015 +0300
summary:
  Issue #23400: Raise same exception on both Python 2 and 3 if sem_open is not available.

Patch by Davin Potts.

files:
  Doc/library/multiprocessing.rst |  24 ++++++++++++++-------
  Lib/multiprocessing/queues.py   |   3 +-
  Misc/NEWS                       |   3 ++
  3 files changed, 21 insertions(+), 9 deletions(-)


diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -262,14 +262,6 @@
 Without using the lock output from the different processes is liable to get all
 mixed up.
 
-.. note::
-
-   Some of this package's functionality requires a functioning shared semaphore
-   implementation on the host operating system. Without one, the
-   :mod:`multiprocessing.synchronize` module will be disabled, and attempts to
-   import it will result in an :exc:`ImportError`. See
-   :issue:`3770` for additional information.
-
 
 Sharing state between processes
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -808,6 +800,14 @@
       immediately without waiting to flush enqueued data to the
       underlying pipe, and you don't care about lost data.
 
+   .. note::
+
+      This class's functionality requires a functioning shared semaphore
+      implementation on the host operating system. Without one, the
+      functionality in this class will be disabled, and attempts to
+      instantiate a :class:`Queue` will result in an :exc:`ImportError`. See
+      :issue:`3770` for additional information.  The same holds true for any
+      of the specialized queue types listed below.
 
 .. class:: SimpleQueue()
 
@@ -1183,6 +1183,14 @@
    This differs from the behaviour of :mod:`threading` where SIGINT will be
    ignored while the equivalent blocking calls are in progress.
 
+.. note::
+
+   Some of this package's functionality requires a functioning shared semaphore
+   implementation on the host operating system. Without one, the
+   :mod:`multiprocessing.synchronize` module will be disabled, and attempts to
+   import it will result in an :exc:`ImportError`. See
+   :issue:`3770` for additional information.
+
 
 Shared :mod:`ctypes` Objects
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -35,7 +35,8 @@
 
     def __init__(self, maxsize=0, *, ctx):
         if maxsize <= 0:
-            maxsize = _multiprocessing.SemLock.SEM_VALUE_MAX
+            # Can raise ImportError (see issues #3770 and #23400)
+            from .synchronize import SEM_VALUE_MAX as maxsize
         self._maxsize = maxsize
         self._reader, self._writer = connection.Pipe(duplex=False)
         self._rlock = ctx.Lock()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@
 - Issue #23881: urllib.request.ftpwrapper constructor now closes the socket if
   the FTP connection failed to fix a ResourceWarning.
 
+- Issue #23400: Raise same exception on both Python 2 and 3 if sem_open is not
+  available.  Patch by Davin Potts.
+
 - Issue #15133: _tkinter.tkapp.getboolean() now supports Tcl_Obj and always
   returns bool.  tkinter.BooleanVar now validates input values (accepted bool,
   int, str, and Tcl_Obj).  tkinter.BooleanVar.get() now always returns bool.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list