Skip to content

Conversation

aisk
Copy link
Member

@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.

@aisk aisk closed this Jul 6, 2025
@AA-Turner AA-Turner removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants