File size: 812 Bytes
58c39e0
8f809e2
3573a39
58c39e0
3573a39
 
92e2a79
 
8f809e2
 
 
1c00552
92e2a79
8f809e2
 
92e2a79
8f809e2
 
 
 
3573a39
 
8f809e2
1c00552
92e2a79
 
8f809e2
3573a39
 
92e2a79
 
8f809e2
 
 
 
1c00552
92e2a79
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
36
37
38
39
import logging
import threading
import time

from io_utils import pop_job_from_pipe

is_running = False


def start_process_run_job():
    try:
        logging.debug("Running jobs in thread")
        global thread, is_running
        thread = threading.Thread(target=run_job)
        thread.daemon = True
        is_running = True
        thread.start()

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


def stop_thread():
    logging.debug("Stop thread")
    global is_running
    is_running = False


def run_job():
    global is_running
    while is_running:
        try:
            pop_job_from_pipe()
            time.sleep(10)
        except KeyboardInterrupt:
            logging.debug("KeyboardInterrupt stop background thread")
            is_running = False
            break