Skip to content

Commit 646225c

Browse files
committed
Document the ctx parameter in some types in multiprocessing
1 parent 490eea0 commit 646225c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

Doc/library/multiprocessing.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ processes.
16601660
attributes which allow one to use it to store and retrieve strings -- see
16611661
documentation for :mod:`ctypes`.
16621662

1663-
.. function:: Array(typecode_or_type, size_or_initializer, *, lock=True)
1663+
.. function:: Array(typecode_or_type, size_or_initializer, *, lock=True, ctx=None)
16641664

16651665
The same as :func:`RawArray` except that depending on the value of *lock* a
16661666
process-safe synchronization wrapper may be returned instead of a raw ctypes
@@ -1674,9 +1674,14 @@ processes.
16741674
automatically protected by a lock, so it will not necessarily be
16751675
"process-safe".
16761676

1677+
*ctx* is a context object, or ``None`` (use the current context). If ``None``,
1678+
calling this function will have the side effect of setting the current global
1679+
start method if it has not been set already. See the :func:`get_context`
1680+
function.
1681+
16771682
Note that *lock* is a keyword-only argument.
16781683

1679-
.. function:: Value(typecode_or_type, *args, lock=True)
1684+
.. function:: Value(typecode_or_type, *args, lock=True, ctx=None)
16801685

16811686
The same as :func:`RawValue` except that depending on the value of *lock* a
16821687
process-safe synchronization wrapper may be returned instead of a raw ctypes
@@ -1689,19 +1694,29 @@ processes.
16891694
automatically protected by a lock, so it will not necessarily be
16901695
"process-safe".
16911696

1697+
*ctx* is a context object, or ``None`` (use the current context). If ``None``,
1698+
calling this function will have the side effect of setting the current global
1699+
start method if it has not been set already. See the :func:`get_context`
1700+
function.
1701+
16921702
Note that *lock* is a keyword-only argument.
16931703

16941704
.. function:: copy(obj)
16951705

16961706
Return a ctypes object allocated from shared memory which is a copy of the
16971707
ctypes object *obj*.
16981708

1699-
.. function:: synchronized(obj[, lock])
1709+
.. function:: synchronized(obj, lock=None, ctx=None)
17001710

17011711
Return a process-safe wrapper object for a ctypes object which uses *lock* to
17021712
synchronize access. If *lock* is ``None`` (the default) then a
17031713
:class:`multiprocessing.RLock` object is created automatically.
17041714

1715+
*ctx* is a context object, or ``None`` (use the current context). If ``None``,
1716+
calling this function will have the side effect of setting the current global
1717+
start method if it has not been set already. See the :func:`get_context`
1718+
function.
1719+
17051720
A synchronized wrapper will have two methods in addition to those of the
17061721
object it wraps: :meth:`get_obj` returns the wrapped object and
17071722
:meth:`get_lock` returns the lock object used for synchronization.
@@ -1819,8 +1834,10 @@ their parent process exits. The manager classes are defined in the
18191834
*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or
18201835
``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization).
18211836

1822-
*ctx* is a context object, or ``None`` (use the current context). See the
1823-
:func:`get_context` function.
1837+
*ctx* is a context object, or ``None`` (use the current context). If ``None``,
1838+
calling this function will have the side effect of setting the current global
1839+
start method if it has not been set already. See the :func:`get_context`
1840+
function.
18241841

18251842
*shutdown_timeout* is a timeout in seconds used to wait until the process
18261843
used by the manager completes in the :meth:`shutdown` method. If the

0 commit comments

Comments
 (0)