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

Function run_in_subinterp_with_config

Lib/test/support/__init__.py:2039–2063  ·  view source on GitHub ↗

Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc module is enabled.

(code, *, own_gil=None, **config)

Source from the content-addressed store, hash-verified

2037
2038
2039def run_in_subinterp_with_config(code, *, own_gil=None, **config):
2040 """
2041 Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc
2042 module is enabled.
2043 """
2044 _check_tracemalloc()
2045 try:
2046 import _testinternalcapi
2047 except ImportError:
2048 raise unittest.SkipTest("requires _testinternalcapi")
2049 if own_gil is not None:
2050 assert 'gil' not in config, (own_gil, config)
2051 config['gil'] = 'own' if own_gil else 'shared'
2052 else:
2053 gil = config['gil']
2054 if gil == 0:
2055 config['gil'] = 'default'
2056 elif gil == 1:
2057 config['gil'] = 'shared'
2058 elif gil == 2:
2059 config['gil'] = 'own'
2060 elif not isinstance(gil, str):
2061 raise NotImplementedError(gil)
2062 config = types.SimpleNamespace(**config)
2063 return _testinternalcapi.run_in_subinterp_with_config(code, config)
2064
2065
2066def _check_tracemalloc():

Callers 1

run_hereMethod · 0.90

Calls 1

_check_tracemallocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…