gh-109070: multiprocessing.get_context will not set the start method globally#135678
gh-109070: multiprocessing.get_context will not set the start method globally#135678aisk wants to merge 1 commit intopython:mainpython/cpython:mainfrom
Conversation
| if self._actual_context is None: | ||
| self._actual_context = self._default_context | ||
| return self._actual_context | ||
| return self._actual_context or self._default_context |
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.