File: _debugger_case_multiple_threads.py

package info (click to toggle)
pydevd 2.9.5%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,880 kB
  • sloc: python: 75,138; cpp: 1,851; sh: 310; makefile: 40; ansic: 4
file content (32 lines) | stat: -rw-r--r-- 646 bytes parent folder | download | duplicates (3)
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
31
32
import threading


class KeepInLoop(object):
    keep_in_loop = True  # Debugger should change to False to break.


def stop_loop():
    KeepInLoop.keep_in_loop = False
    return 'stopped_loop'


def double_number(number):
    while KeepInLoop.keep_in_loop:
        doubled = number * 2
        print(doubled)
        import time
        time.sleep(.5)
    return doubled


if __name__ == '__main__':
    threads = []
    for num in range(2):
        thread = threading.Thread(target=double_number, args=(num,))
        thread.start()
        threads.append(thread)

    for thread in threads:
        thread.join()

    print('TEST SUCEEDED!')