8000 gh-109070: multiprocessing.get_context will not set the start method globally by aisk · Pull Request #135678 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109070: multiprocessing.get_context will not set the start method globally #135678

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aisk
Copy link
Contributor
@aisk aisk commented Jun 18, 2025

Copy link
@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

if self._actual_context is None:
self._actual_context = self._default_context
return self._actual_context
return self._actual_context or self._default_context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I could say "or perhaps even just return self._default_context?" given the documentation for .get_context() today. BUT code relies on .get_context() to establish the actual set context and thus prevent it from being changed without force=True so that different contexts are not used between API surfaces at the default module level (Lib/multiprocessing/__init__.py sets module level attributes to be the multiprocessing.context._default_context instance attributes)

So I think we really are best off just documenting the existing behavior. As is already done for get_start_method() in the docs right below get_context() - https://docs.python.org/3/library/multiprocessing.html
Examples: All of the things defined in BaseContext that when used have a ctx=self.get_context() call in them. Once something is used with the default context we don't want to allow a set_start_method call to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0