Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 291d7b0

Browse files
committed
Issue #23400: Raise same exception on both Python 2 and 3 if sem_open is not available.
Patch by Davin Potts.
2 parents b8e973f + 7ecfc82 commit 291d7b0

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,6 @@ that only one process prints to standard output at a time::
262262
Without using the lock output from the different processes is liable to get all
263263
mixed up.
264264

265-
.. note::
266-
267-
Some of this package's functionality requires a functioning shared semaphore
268-
implementation on the host operating system. Without one, the
269-
:mod:`multiprocessing.synchronize` module will be disabled, and attempts to
270-
import it will result in an :exc:`ImportError`. See
271-
:issue:`3770` for additional information.
272-
273265

274266
Sharing state between processes
275267
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -808,6 +800,14 @@ For an example of the usage of queues for interprocess communication see
808800
immediately without waiting to flush enqueued data to the
809801
underlying pipe, and you don't care about lost data.
810802

803+
.. note::
804+
805+
This class's functionality requires a functioning shared semaphore
806+
implementation on the host operating system. Without one, the
807+
functionality in this class will be disabled, and attempts to
808+
instantiate a :class:`Queue` will result in an :exc:`ImportError`. See
809+
:issue:`3770` for additional information. The same holds true for any
810+
of the specialized queue types listed below.
811811

812812
.. class:: SimpleQueue()
813813

@@ -1183,6 +1183,14 @@ object -- see :ref:`multiprocessing-managers`.
11831183
This differs from the behaviour of :mod:`threading` where SIGINT will be
11841184
ignored while the equivalent blocking calls are in progress.
11851185

1186+
.. note::
1187+
1188+
Some of this package's functionality requires a functioning shared semaphore
1189+
implementation on the host operating system. Without one, the
1190+
:mod:`multiprocessing.synchronize` module will be disabled, and attempts to
1191+
import it will result in an :exc:`ImportError`. See
1192+
:issue:`3770` for additional information.
1193+
11861194

11871195
Shared :mod:`ctypes` Objects
11881196
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Lib/multiprocessing/queues.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Queue(object):
3535

3636
def __init__(self, maxsize=0, *, ctx):
3737
if maxsize <= 0:
38-
maxsize = _multiprocessing.SemLock.SEM_VALUE_MAX
38+
# Can raise ImportError (see issues #3770 and #23400)
39+
from .synchronize import SEM_VALUE_MAX as maxsize
3940
self._maxsize = maxsize
4041
self._reader, self._writer = connection.Pipe(duplex=False)
4142
self._rlock = ctx.Lock()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Core and Builtins
1919
Library
2020
-------
2121

22+
- Issue #23400: Raise same exception on both Python 2 and 3 if sem_open is not
23+
available. Patch by Davin Potts.
24+
2225
- Issue #10838: The subprocess now module includes SubprocessError and
2326
TimeoutError in its list of exported names for the users wild enough
2427
to use "from subprocess import *".

0 commit comments

Comments
 (0)