@@ -132,7 +132,10 @@ instances::
132
132
133
133
The following example demonstrates a practical use of the :class: `SharedMemory `
134
134
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
136
139
137
140
>>> # In the first Python interactive shell
138
141
>>> import numpy as np
@@ -252,6 +255,9 @@ same ``numpy.ndarray`` from two distinct Python shells::
252
255
The following example demonstrates the basic mechanisms of a
253
256
:class: `SharedMemoryManager `:
254
257
258
+ .. doctest ::
259
+ :options: +SKIP
260
+
255
261
>>> from multiprocessing import shared_memory
256
262
>>> smm = shared_memory.SharedMemoryManager()
257
263
>>> 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
269
275
ensure that all shared memory blocks are released after they are no longer
270
276
needed:
271
277
278
+ .. doctest ::
279
+ :options: +SKIP
280
+
272
281
>>> with shared_memory.SharedMemoryManager() as smm:
273
282
... sl = smm.ShareableList(range (2000 ))
274
283
... # Divide the work among two processes, storing partial results in sl
@@ -346,9 +355,7 @@ instance:
346
355
'dry ice'
347
356
>>> a[2 ] = ' larger than previously allocated storage space'
348
357
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
+ ...
352
359
ValueError: exceeds available storage for existing str
353
360
>>> a[2 ]
354
361
'dry ice'
@@ -371,7 +378,7 @@ behind it:
371
378
>>> b = shared_memory.ShareableList(range (5 )) # In a first process
372
379
>>> c = shared_memory.ShareableList(name = b.shm.name) # In a second process
373
380
>>> c
374
- ShareableList([0, 1, 2, 3, 4], name='psm_25144_23776 ')
381
+ ShareableList([0, 1, 2, 3, 4], name='... ')
375
382
>>> c[- 1 ] = - 999
376
383
>>> b[- 1 ]
377
384
-999
0 commit comments