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

Method run_here

Lib/test/test_import/__init__.py:2226–2260  ·  view source on GitHub ↗

Try importing the named module in a subinterpreter. The subinterpreter will be in the current process. The module will have already been imported in the main interpreter. Thus, for extension/builtin modules, the module definition will have been loaded alread

(self, name, filename=None, *,
                 check_singlephase_setting=False,
                 check_singlephase_override=None,
                 isolated=False,
                 )

Source from the content-addressed store, hash-verified

2224 ''')
2225
2226 def run_here(self, name, filename=None, *,
2227 check_singlephase_setting=False,
2228 check_singlephase_override=None,
2229 isolated=False,
2230 ):
2231 """
2232 Try importing the named module in a subinterpreter.
2233
2234 The subinterpreter will be in the current process.
2235 The module will have already been imported in the main interpreter.
2236 Thus, for extension/builtin modules, the module definition will
2237 have been loaded already and cached globally.
2238
2239 "check_singlephase_setting" determines whether or not
2240 the interpreter will be configured to check for modules
2241 that are not compatible with use in multiple interpreters.
2242
2243 This should always return "okay" for all modules if the
2244 setting is False (with no override).
2245 """
2246 __import__(name)
2247
2248 kwargs = dict(
2249 **self.RUN_KWARGS,
2250 **(self.ISOLATED if isolated else self.NOT_ISOLATED),
2251 check_multi_interp_extensions=check_singlephase_setting,
2252 )
2253
2254 r, w = self.pipe()
2255 script = self.import_script(name, w, filename,
2256 check_singlephase_override)
2257
2258 ret = run_in_subinterp_with_config(script, **kwargs)
2259 self.assertEqual(ret, 0)
2260 return os.read(r, 100)
2261
2262 def check_compatible_here(self, name, filename=None, *,
2263 strict=False,

Callers 4

check_compatible_hereMethod · 0.95
check_compatibleMethod · 0.95
check_incompatibleMethod · 0.95

Calls 6

pipeMethod · 0.95
import_scriptMethod · 0.95
__import__Function · 0.85
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected