File size: 723 Bytes
8f809e2
3573a39
136af2d
3573a39
 
8f809e2
 
 
 
3573a39
8f809e2
 
 
136af2d
8f809e2
 
 
 
3573a39
 
8f809e2
 
 
 
3573a39
 
8f809e2
 
 
 
 
 
 
3573a39
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
33
34
35
import threading
import time
import pipe
from io_utils import pop_job_from_pipe


def start_process_run_job():
    try:
        print("Running jobs in thread")
        global thread
        thread = threading.Thread(target=run_job)
        thread.daemon = True
        thread.do_run = True
        pipe.init()
        thread.start()

    except Exception as e:
        print("Failed to start thread: ", e)


def stop_thread():
    print("Stop thread")
    thread.do_run = False


def run_job():
    while True:
        try:
            pop_job_from_pipe()
            time.sleep(10)
        except KeyboardInterrupt:
            print("KeyboardInterrupt stop background thread")
            stop_thread()
            break