Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-109070: Document thatmultiprocessing.get_context() sets the global context#109488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rajveer43 wants to merge8 commits intopython:main
base:main
Choose a base branch
Loading
fromrajveer43:fix-issue-109070-main
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletionsDoc/library/multiprocessing.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1058,24 +1058,40 @@ Miscellaneous
Return a context object which has the same attributes as the
:mod:`multiprocessing` module.

If *method* is ``None`` then the default context is returned.
Otherwise *method* should be ``'fork'``, ``'spawn'``,
``'forkserver'``. :exc:`ValueError` is raised if the specified
start method is not available. See :ref:`multiprocessing-start-methods`.
If *method* is ``None``, the default context is returned. Be aware that
calling this function with *method=None* sets the default context globally,
potentially affecting future usage of :func:`set_start_method`. To change
the method later, it is recommended to explicitly specify a method other
than ``None`` when calling this function. Otherwise, it may lead to
unexpected behavior.

*method* should be one of the following: ``'fork'``, ``'spawn'``, or
``'forkserver'``. A :exc:`ValueError` is raised if the specified start
method is unavailable. See :ref:`multiprocessing-start-methods`.

.. versionadded:: 3.4

.. function:: get_start_method(allow_none=False)

Return the name of start method used for starting processes.

If the start method has not been fixed and *allow_none* is false,
then the start method is fixed to the default and the name is
returned. If the start method has not been fixed and *allow_none*
is true then ``None`` is returned.
If the start method has not been explicitly set
(e.g., using :func:`set_start_method`) and *allow_none* is false, then the
start method is fixed to the default, and the name of the default method
is returned. If the start method has not been explicitly set and
*allow_none* is true, then ``None`` is returned, indicating that
the method has not been explicitly set.

The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'``
or ``None``. See :ref:`multiprocessing-start-methods`.
or ``None``.

Exercise caution when changing the start method using
``multiprocessing.set_start_method`` after using
``multiprocessing.get_start_method`` with *allow_none* set to
``False``, as it may raise a ``RuntimeError``.

See :ref:`multiprocessing-start-methods` for more information
on multiprocessing start methods and their implications.

.. versionchanged:: 3.8

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp