From 86da27a7a1cd908a70c9922d15f1f07d2647d110 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Fri, 28 Oct 2022 22:52:00 -0400 Subject: [PATCH] Moved wait outside lock and now returns false on failure. --- ui/sd_internal/task_manager.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/sd_internal/task_manager.py b/ui/sd_internal/task_manager.py index 01d7bf0a..eae17891 100644 --- a/ui/sd_internal/task_manager.py +++ b/ui/sd_internal/task_manager.py @@ -375,14 +375,16 @@ def start_render_thread(device='auto'): rthread.daemon = True rthread.name = THREAD_NAME_PREFIX + device rthread.start() - timeout = DEVICE_START_TIMEOUT - while not rthread.is_alive() or not rthread in weak_thread_data or not 'device' in weak_thread_data[rthread]: - if timeout <= 0: raise Exception('render_thread', rthread.name, 'failed to start before timeout or has crashed.') - timeout -= 1 - time.sleep(1) render_threads.append(rthread) finally: manager_lock.release() + timeout = DEVICE_START_TIMEOUT + while not rthread.is_alive() or not rthread in weak_thread_data or not 'device' in weak_thread_data[rthread]: + if timeout <= 0: + return False + timeout -= 1 + time.sleep(1) + return True def shutdown_event(): # Signal render thread to close on shutdown global current_state_error