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

Function _running

Lib/test/test__interpreters.py:54–71  ·  view source on GitHub ↗
(interp)

Source from the content-addressed store, hash-verified

52
53@contextlib.contextmanager
54def _running(interp):
55 r, w = os.pipe()
56 def run():
57 _interpreters.run_string(interp, dedent(f"""
58 # wait for "signal"
59 with open({r}, encoding="utf-8") as rpipe:
60 rpipe.read()
61 """))
62
63 t = threading.Thread(target=run)
64 t.start()
65 _wait_for_interp_to_run(interp)
66
67 yield
68
69 with open(w, 'w', encoding="utf-8") as spipe:
70 spipe.write('done')
71 t.join()
72
73
74def clean_up_interpreters():

Callers 3

test_subinterpreterMethod · 0.70
test_still_runningMethod · 0.70
test_already_runningMethod · 0.70

Calls 6

startMethod · 0.95
joinMethod · 0.95
_wait_for_interp_to_runFunction · 0.85
openFunction · 0.50
pipeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…