Skip to content

Commit eec4bb1

Browse files
committed
Added Sphinx doctest run controls.
1 parent 7bdfbbb commit eec4bb1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Doc/library/multiprocessing.shared_memory.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ instances::
132132

133133
The following example demonstrates a practical use of the :class:`SharedMemory`
134134
class with `NumPy arrays <https://www.numpy.org/>`_, accessing the
135-
same ``numpy.ndarray`` from two distinct Python shells::
135+
same ``numpy.ndarray`` from two distinct Python shells:
136+
137+
.. doctest::
138+
:options: +SKIP
136139

137140
>>> # In the first Python interactive shell
138141
>>> import numpy as np
@@ -252,6 +255,9 @@ same ``numpy.ndarray`` from two distinct Python shells::
252255
The following example demonstrates the basic mechanisms of a
253256
:class:`SharedMemoryManager`:
254257

258+
.. doctest::
259+
:options: +SKIP
260+
255261
>>> from multiprocessing import shared_memory
256262
>>> smm = shared_memory.SharedMemoryManager()
257263
>>> smm.start() # Start the process that manages the shared memory blocks
@@ -269,6 +275,9 @@ The following example depicts a potentially more convenient pattern for using
269275
ensure that all shared memory blocks are released after they are no longer
270276
needed:
271277

278+
.. doctest::
279+
:options: +SKIP
280+
272281
>>> with shared_memory.SharedMemoryManager() as smm:
273282
... sl = smm.ShareableList(range(2000))
274283
... # Divide the work among two processes, storing partial results in sl
@@ -346,9 +355,7 @@ instance:
346355
'dry ice'
347356
>>> a[2] = 'larger than previously allocated storage space'
348357
Traceback (most recent call last):
349-
File "<stdin>", line 1, in <module>
350-
File "/usr/local/lib/python3.8/multiprocessing/shared_memory.py", line 429, in __setitem__
351-
raise ValueError("exceeds available storage for existing str")
358+
...
352359
ValueError: exceeds available storage for existing str
353360
>>> a[2]
354361
'dry ice'
@@ -371,7 +378,7 @@ behind it:
371378
>>> b = shared_memory.ShareableList(range(5)) # In a first process
372379
>>> c = shared_memory.ShareableList(name=b.shm.name) # In a second process
373380
>>> c
374-
ShareableList([0, 1, 2, 3, 4], name='psm_25144_23776')
381+
ShareableList([0, 1, 2, 3, 4], name='...')
375382
>>> c[-1] = -999
376383
>>> b[-1]
377384
-999

0 commit comments

Comments
 (0)