MCPcopy Index your code
hub / github.com/python/cpython / DefaultContext

Class DefaultContext

Lib/multiprocessing/context.py:239–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237 return _default_context.get_context().Process._after_fork()
238
239class DefaultContext(BaseContext):
240 Process = Process
241
242 def __init__(self, context):
243 self._default_context = context
244 self._actual_context = None
245
246 def get_context(self, method=None):
247 if method is None:
248 if self._actual_context is None:
249 self._actual_context = self._default_context
250 return self._actual_context
251 else:
252 return super().get_context(method)
253
254 def set_start_method(self, method, force=False):
255 if self._actual_context is not None and not force:
256 raise RuntimeError('context has already been set')
257 if method is None and force:
258 self._actual_context = None
259 return
260 self._actual_context = self.get_context(method)
261
262 def get_start_method(self, allow_none=False):
263 if self._actual_context is None:
264 if allow_none:
265 return None
266 self._actual_context = self._default_context
267 return self._actual_context._name
268
269 def get_all_start_methods(self):
270 """Returns a list of the supported start methods, default first."""
271 default = self._default_context.get_start_method()
272 start_method_names = [default]
273 start_method_names.extend(
274 name for name in _concrete_contexts if name != default
275 )
276 return start_method_names
277
278
279#

Callers 1

context.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…