Skip to content

Commit 2122e1e

Browse files
[3.11] Docs: Improve multiprocessing.SharedMemory reference (#114093) (#114138)
(cherry picked from b1db627) Align the multiprocessing shared memory docs with Diatáxis's recommendations for references. - use a parameter list for the SharedMemory.__init__() argument spec - use the imperative mode - use versionadded, not versionchanged, for added parameters - reflow touched lines according to SemBr
1 parent ddc9e34 commit 2122e1e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

Doc/library/multiprocessing.shared_memory.rst

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ copying of data.
3838

3939
.. class:: SharedMemory(name=None, create=False, size=0)
4040

41-
Creates a new shared memory block or attaches to an existing shared
41+
Create an instance of the :class:`!SharedMemory` class for either
42+
creating a new shared memory block or attaching to an existing shared
4243
memory block. Each shared memory block is assigned a unique name.
4344
In this way, one process can create a shared memory block with a
4445
particular name and a different process can attach to that same shared
@@ -51,30 +52,35 @@ copying of data.
5152
When a shared memory block is no longer needed by any process, the
5253
:meth:`unlink` method should be called to ensure proper cleanup.
5354

54-
*name* is the unique name for the requested shared memory, specified as
55-
a string. When creating a new shared memory block, if ``None`` (the
56-
default) is supplied for the name, a novel name will be generated.
55+
:param name:
56+
The unique name for the requested shared memory, specified as a string.
57+
When creating a new shared memory block, if ``None`` (the default)
58+
is supplied for the name, a novel name will be generated.
59+
:type name: str | None
5760

58-
*create* controls whether a new shared memory block is created (``True``)
59-
or an existing shared memory block is attached (``False``).
61+
:param bool create:
62+
Control whether a new shared memory block is created (``True``)
63+
or an existing shared memory block is attached (``False``).
6064

61-
*size* specifies the requested number of bytes when creating a new shared
62-
memory block. Because some platforms choose to allocate chunks of memory
63-
based upon that platform's memory page size, the exact size of the shared
64-
memory block may be larger or equal to the size requested. When attaching
65-
to an existing shared memory block, the *size* parameter is ignored.
65+
:param int size:
66+
The requested number of bytes when creating a new shared memory block.
67+
Because some platforms choose to allocate chunks of memory
68+
based upon that platform's memory page size, the exact size of the shared
69+
memory block may be larger or equal to the size requested.
70+
When attaching to an existing shared memory block,
71+
the *size* parameter is ignored.
6672

6773
.. method:: close()
6874

69-
Closes access to the shared memory from this instance. In order to
75+
Close access to the shared memory from this instance. In order to
7076
ensure proper cleanup of resources, all instances should call
7177
:meth:`close` once the instance is no longer needed. Note that calling
7278
:meth:`!close` does not cause the shared memory block itself to be
7379
destroyed.
7480

7581
.. method:: unlink()
7682

77-
Requests that the underlying shared memory block be destroyed. In
83+
Request that the underlying shared memory block be destroyed. In
7884
order to ensure proper cleanup of resources, :meth:`unlink` should be
7985
called once (and only once) across all processes which have need
8086
for the shared memory block. After requesting its destruction, a
@@ -258,7 +264,7 @@ finishes execution.
258264

259265
.. class:: ShareableList(sequence=None, *, name=None)
260266

261-
Provides a mutable list-like object where all values stored within are
267+
Provide a mutable list-like object where all values stored within are
262268
stored in a shared memory block.
263269
This constrains storable values to the following built-in data types:
264270

@@ -315,12 +321,12 @@ finishes execution.
315321

316322
.. method:: count(value)
317323

318-
Returns the number of occurrences of *value*.
324+
Return the number of occurrences of *value*.
319325

320326
.. method:: index(value)
321327

322-
Returns first index position of *value*. Raises :exc:`ValueError` if
323-
*value* is not present.
328+
Return first index position of *value*.
329+
Raise :exc:`ValueError` if *value* is not present.
324330

325331
.. attribute:: format
326332

0 commit comments

Comments
 (0)