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

Skip to content

Commit 3b7e47a

Browse files
pierreglasermiss-islington
authored andcommitted
bpo-36364: fix SharedMemoryManager examples (GH-12439)
Examples of the `multiprocessing.shared_memory` module try to import `SharedMemoryManager` from `multiprocessing.shared_memory` whereas this class is defined in `multiprocessing.managers`.
1 parent f8ba6f5 commit 3b7e47a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Doc/library/multiprocessing.shared_memory.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ same ``numpy.ndarray`` from two distinct Python shells:
176176

177177

178178
.. class:: SharedMemoryManager([address[, authkey]])
179+
:module: multiprocessing.managers
179180

180181
A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
181182
used for the management of shared memory blocks across processes.
@@ -218,8 +219,8 @@ The following example demonstrates the basic mechanisms of a
218219
.. doctest::
219220
:options: +SKIP
220221

221-
>>> from multiprocessing import shared_memory
222-
>>> smm = shared_memory.SharedMemoryManager()
222+
>>> from multiprocessing.managers import SharedMemoryManager
223+
>>> smm = SharedMemoryManager()
223224
>>> smm.start() # Start the process that manages the shared memory blocks
224225
>>> sl = smm.ShareableList(range(4))
225226
>>> sl
@@ -238,7 +239,7 @@ needed:
238239
.. doctest::
239240
:options: +SKIP
240241

241-
>>> with shared_memory.SharedMemoryManager() as smm:
242+
>>> with SharedMemoryManager() as smm:
242243
... sl = smm.ShareableList(range(2000))
243244
... # Divide the work among two processes, storing partial results in sl
244245
... p1 = Process(target=do_work, args=(sl, 0, 1000))

0 commit comments

Comments
 (0)