-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest.py
More file actions
30 lines (21 loc) · 770 Bytes
/
test.py
File metadata and controls
30 lines (21 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import _xxsubinterpreters as interpreters
from threading import Thread
import textwrap as tw
def test_threading_interpreter():
interp = interpreters.create()
def t():
interpreters.run_string(interp,tw.dedent("""
import time
for _ in range(50):
print(end='.', flush=True)
time.sleep(0.05)
print("End of interp job")
"""))
thread = Thread(target = t)
print(f"Before thread.start(), {interpreters.is_running(interp) = }")
thread.start()
print(f"After thread.start(), {interpreters.is_running(interp) = }")
thread.join()
print(f"After thread.join(), {interpreters.is_running(interp) = }")
if __name__ == "__main__":
test_threading_interpreter()