bpo-36364: fix SharedMemoryManager examples (GH-12439) · python/cpython@3b7e47a (original) (raw)

``` @@ -176,6 +176,7 @@ same numpy.ndarray from two distinct Python shells:

```

176

176

``

177

177

``

178

178

`.. class:: SharedMemoryManager([address[, authkey]])

`

``

179

`+

:module: multiprocessing.managers

`

179

180

``

180

181

`` A subclass of :class:~multiprocessing.managers.BaseManager which can be

``

181

182

` used for the management of shared memory blocks across processes.

`

`@@ -218,8 +219,8 @@ The following example demonstrates the basic mechanisms of a

`

218

219

`.. doctest::

`

219

220

`:options: +SKIP

`

220

221

``

221

``

`-

from multiprocessing import shared_memory

`

222

``

`-

smm = shared_memory.SharedMemoryManager()

`

``

222

`+

from multiprocessing.managers import SharedMemoryManager

`

``

223

`+

smm = SharedMemoryManager()

`

223

224

` >>> smm.start() # Start the process that manages the shared memory blocks

`

224

225

` >>> sl = smm.ShareableList(range(4))

`

225

226

` >>> sl

`

`@@ -238,7 +239,7 @@ needed:

`

238

239

`.. doctest::

`

239

240

`:options: +SKIP

`

240

241

``

241

``

`-

with shared_memory.SharedMemoryManager() as smm:

`

``

242

`+

with SharedMemoryManager() as smm:

`

242

243

` ... sl = smm.ShareableList(range(2000))

`

243

244

` ... # Divide the work among two processes, storing partial results in sl

`

244

245

` ... p1 = Process(target=do_work, args=(sl, 0, 1000))

`