@@ -38,7 +38,8 @@ copying of data.
3838
3939.. class :: SharedMemory(name=None, create=False, size=0, *, track=True)
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,41 +52,48 @@ 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.
57-
58- *create * controls whether a new shared memory block is created (``True ``)
59- or an existing shared memory block is attached (``False ``).
60-
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.
66-
67- *track *, when enabled, registers the shared memory block with a resource
68- tracker process on platforms where the OS does not do this automatically.
69- The resource tracker ensures proper cleanup of the shared memory even
70- if all other processes with access to the memory exit without doing so.
71- Python processes created from a common ancestor using :mod: `multiprocessing `
72- facilities share a single resource tracker process, and the lifetime of
73- shared memory segments is handled automatically among these processes.
74- Python processes created in any other way will receive their own
75- resource tracker when accessing shared memory with *track * enabled.
76- This will cause the shared memory to be deleted by the resource tracker
77- of the first process that terminates.
78- To avoid this issue, users of :mod: `subprocess ` or standalone Python
79- processes should set *track * to ``False `` when there is already another
80- process in place that does the bookkeeping.
81- *track * is ignored on Windows, which has its own tracking and
82- automatically deletes shared memory when all handles to it have been closed.
83-
84- .. versionchanged :: 3.13 Added *track* parameter.
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
60+
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 ``).
64+
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.
72+
73+ :param bool track:
74+ When ``True ``, register the shared memory block with a resource
75+ tracker process on platforms where the OS does not do this automatically.
76+ The resource tracker ensures proper cleanup of the shared memory even
77+ if all other processes with access to the memory exit without doing so.
78+ Python processes created from a common ancestor using :mod: `multiprocessing `
79+ facilities share a single resource tracker process, and the lifetime of
80+ shared memory segments is handled automatically among these processes.
81+ Python processes created in any other way will receive their own
82+ resource tracker when accessing shared memory with *track * enabled.
83+ This will cause the shared memory to be deleted by the resource tracker
84+ of the first process that terminates.
85+ To avoid this issue, users of :mod: `subprocess ` or standalone Python
86+ processes should set *track * to ``False `` when there is already another
87+ process in place that does the bookkeeping.
88+ *track * is ignored on Windows, which has its own tracking and
89+ automatically deletes shared memory when all handles to it have been closed.
90+
91+ .. versionadded :: 3.13
92+ The *track * parameter.
8593
8694 .. method :: close()
8795
88- Closes the file descriptor/handle to the shared memory from this
96+ Close the file descriptor/handle to the shared memory from this
8997 instance. :meth: `close ` should be called once access to the shared
9098 memory block from this instance is no longer needed. Depending
9199 on operating system, the underlying memory may or may not be freed
@@ -94,7 +102,7 @@ copying of data.
94102
95103 .. method :: unlink()
96104
97- Deletes the underlying shared memory block. This should be called only
105+ Delete the underlying shared memory block. This should be called only
98106 once per shared memory block regardless of the number of handles to it,
99107 even in other processes.
100108 :meth: `unlink ` and :meth: `close ` can be called in any order, but
@@ -277,7 +285,7 @@ finishes execution.
277285
278286.. class :: ShareableList(sequence=None, *, name=None)
279287
280- Provides a mutable list-like object where all values stored within are
288+ Provide a mutable list-like object where all values stored within are
281289 stored in a shared memory block.
282290 This constrains storable values to the following built-in data types:
283291
@@ -334,12 +342,12 @@ finishes execution.
334342
335343 .. method :: count(value)
336344
337- Returns the number of occurrences of *value *.
345+ Return the number of occurrences of *value *.
338346
339347 .. method :: index(value)
340348
341- Returns first index position of *value *. Raises :exc: ` ValueError ` if
342- *value * is not present.
349+ Return first index position of *value *.
350+ Raise :exc: ` ValueError ` if *value * is not present.
343351
344352 .. attribute :: format
345353
0 commit comments