mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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`.
This commit is contained in:
parent
f8ba6f5afc
commit
3b7e47aea9
1 changed files with 4 additions and 3 deletions
|
@ -176,6 +176,7 @@ same ``numpy.ndarray`` from two distinct Python shells:
|
||||||
|
|
||||||
|
|
||||||
.. class:: SharedMemoryManager([address[, authkey]])
|
.. class:: SharedMemoryManager([address[, authkey]])
|
||||||
|
:module: multiprocessing.managers
|
||||||
|
|
||||||
A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
|
A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
|
||||||
used for the management of shared memory blocks across processes.
|
used for the management of shared memory blocks across processes.
|
||||||
|
@ -218,8 +219,8 @@ The following example demonstrates the basic mechanisms of a
|
||||||
.. doctest::
|
.. doctest::
|
||||||
:options: +SKIP
|
:options: +SKIP
|
||||||
|
|
||||||
>>> from multiprocessing import shared_memory
|
>>> from multiprocessing.managers import SharedMemoryManager
|
||||||
>>> smm = shared_memory.SharedMemoryManager()
|
>>> smm = SharedMemoryManager()
|
||||||
>>> smm.start() # Start the process that manages the shared memory blocks
|
>>> smm.start() # Start the process that manages the shared memory blocks
|
||||||
>>> sl = smm.ShareableList(range(4))
|
>>> sl = smm.ShareableList(range(4))
|
||||||
>>> sl
|
>>> sl
|
||||||
|
@ -238,7 +239,7 @@ needed:
|
||||||
.. doctest::
|
.. doctest::
|
||||||
:options: +SKIP
|
:options: +SKIP
|
||||||
|
|
||||||
>>> with shared_memory.SharedMemoryManager() as smm:
|
>>> with SharedMemoryManager() as smm:
|
||||||
... sl = smm.ShareableList(range(2000))
|
... sl = smm.ShareableList(range(2000))
|
||||||
... # Divide the work among two processes, storing partial results in sl
|
... # Divide the work among two processes, storing partial results in sl
|
||||||
... p1 = Process(target=do_work, args=(sl, 0, 1000))
|
... p1 = Process(target=do_work, args=(sl, 0, 1000))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue