giskard-evaluator / run_jobs.py
inoki-giskard's picture
Use a flag to stop a thread because it cannot capture keyboard event
92e2a79
raw history blame
No virus
805 Bytes
import threading
import time
import pipe
from io_utils import pop_job_from_pipe
is_running = False
def start_process_run_job():
try:
print("Running jobs in thread")
global thread, is_running
thread = threading.Thread(target=run_job)
thread.daemon = True
is_running = True
pipe.init()
thread.start()
except Exception as e:
print("Failed to start thread: ", e)
def stop_thread():
print("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:
print("KeyboardInterrupt stop background thread")
is_running = False
break