Files
openide/python/testData/debug/test_two_threads.py
Elizaveta Shashkova 34045abb37 Fix working with threads in frame evaluation debugger (PY-22450, PY-22454)
We need to use old tracing function for suspending threads without breakpoint. Also sys.settrace() should be called inside a thread, that's why we pass this command as internal thread command.
2017-02-14 15:06:50 +03:00

26 lines
458 B
Python

from threading import Thread
from time import sleep
def print_with_pause(text, pause):
sleep(pause)
print(text)
def fun1(n):
while True:
print_with_pause("Thread1", 0.1)
def fun2(m):
sleep(2)
while True:
print_with_pause("Thread2", 0.1) # breakpoint
threads = [Thread(target=fun1, args=(24,), name="Thread1"),
Thread(target=fun2, args=(42,), name="Thread2")]
for thread in threads:
thread.start()