Skip to content

Commit 1697860

Browse files
committed
Update multiprocessing.rst
1 parent 929cc4e commit 1697860

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

Doc/library/multiprocessing.rst

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,24 +1052,42 @@ Miscellaneous
10521052
Return a context object which has the same attributes as the
10531053
:mod:`multiprocessing` module.
10541054

1055-
If *method* is ``None`` then the default context is returned.
1056-
Otherwise *method* should be ``'fork'``, ``'spawn'``,
1057-
``'forkserver'``. :exc:`ValueError` is raised if the specified
1058-
start method is not available. See :ref:`multiprocessing-start-methods`.
1055+
If *method* is ``None``, then the default context is returned.
1056+
This method sets the default context globally, which may affect
1057+
future usage of :func:`set_start_method`. If you wish to change the
1058+
method later, it is recommended to explicitly specify a method other
1059+
than ``None`` when calling this function. Otherwise, unexpected behavior
1060+
may occur.
1061+
1062+
*method* should be one of the following:
1063+
``'fork'``, ``'spawn'``, or ``'forkserver'``.
1064+
:exc:`ValueError` is raised if the specified start
1065+
method is not available. See :ref:`multiprocessing-start-methods`.
10591066

10601067
.. versionadded:: 3.4
10611068

10621069
.. function:: get_start_method(allow_none=False)
10631070

1064-
Return the name of start method used for starting processes.
1071+
Return the name of the start method used for starting processes.
10651072

1066-
If the start method has not been fixed and *allow_none* is false,
1067-
then the start method is fixed to the default and the name is
1068-
returned. If the start method has not been fixed and *allow_none*
1069-
is true then ``None`` is returned.
1073+
If the start method has not been explicitly set
1074+
(e.g., using :func:`set_start_method`) and *allow_none* is false,
1075+
then the start method is fixed to the default and the name of the
1076+
default method is returned. If the start method has not been explicitly
1077+
set and *allow_none* is true, then ``None`` is returned, indicating that
1078+
the method has not been explicitly set.
10701079

1071-
The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'``
1072-
or ``None``. See :ref:`multiprocessing-start-methods`.
1080+
The return value can be one of the following:
1081+
``'fork'``, ``'spawn'``, ``'forkserver'``, or ``None``.
1082+
1083+
.. note:: Changing the start method using ``multiprocessing.set_start_method``
1084+
after using ``multiprocessing.get_start_method`` with *allow_none* set to ``False``
1085+
may raise a ``RuntimeError``. Be cautious when changing the start method
1086+
after it has been set.
1087+
1088+
See
1089+
:ref:`multiprocessing-start-methods` for more information on multiprocessing start
1090+
methods and their implications.
10731091

10741092
.. versionchanged:: 3.8
10751093

0 commit comments

Comments
 (0)