From e66e7f1bd01d65413bb742edea43ab659efd3423 Mon Sep 17 00:00:00 2001 From: Brendan Haines Date: Mon, 2 Mar 2020 21:55:06 -0700 Subject: [PATCH] more thread fixes --- Software/python/hwtest.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Software/python/hwtest.py b/Software/python/hwtest.py index c09462c..678cefb 100644 --- a/Software/python/hwtest.py +++ b/Software/python/hwtest.py @@ -139,7 +139,7 @@ def controller(): # TODO: replace sleep statement with something that doesn't depend on execution time of loop time.sleep(sample_interval) -control_thread = threading.Thread(target=controller) +control_thread = None # Callback functions def update_plots(attrname=None, old=None, new=None): @@ -163,13 +163,18 @@ def start_controller(attrname=None, old=None, new=None): global control_thread global control_thread_run control_thread_run = True + control_thread = threading.Thread(target=controller) control_thread.start() def stop_controller(attrname=None, old=None, new=None): global control_thread global control_thread_run - control_thread_run = False - control_thread.join() + try: + control_thread_run = False + control_thread.join() + control_thread = None + except: + pass # GUI elements cal_white_button = Button(label="Cal White")