From e43bf2b93ae6388ae2f5e77438245d7a5e7bc2d0 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 10 Jul 2023 09:01:48 +0530 Subject: [PATCH] Revert the speed up from starting the browser early. Not sure why the fastapi server isn't ready to serve static html by this point, will need to investigate later --- ui/easydiffusion/task_manager.py | 28 ++++++++++++++-------------- ui/main.py | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ui/easydiffusion/task_manager.py b/ui/easydiffusion/task_manager.py index 608da41d..a91cd9c6 100644 --- a/ui/easydiffusion/task_manager.py +++ b/ui/easydiffusion/task_manager.py @@ -473,15 +473,15 @@ def start_render_thread(device): 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 rthread in weak_thread_data and "error" in weak_thread_data[rthread]: - # log.error(f"{rthread}, {device}, error: {weak_thread_data[rthread]['error']}") - # return False - # if timeout <= 0: - # return False - # timeout -= 1 - # time.sleep(1) + 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 rthread in weak_thread_data and "error" in weak_thread_data[rthread]: + log.error(f"{rthread}, {device}, error: {weak_thread_data[rthread]['error']}") + return False + if timeout <= 0: + return False + timeout -= 1 + time.sleep(1) return True @@ -535,12 +535,12 @@ def update_render_threads(render_devices, active_devices): if not start_render_thread(device): log.warn(f"{device} failed to start.") - # if is_alive() <= 0: # No running devices, probably invalid user config. - # raise EnvironmentError( - # 'ERROR: No active render devices! Please verify the "render_devices" value in config.json' - # ) + if is_alive() <= 0: # No running devices, probably invalid user config. + raise EnvironmentError( + 'ERROR: No active render devices! Please verify the "render_devices" value in config.json' + ) - # log.debug(f"active devices: {get_devices()['active']}") + log.debug(f"active devices: {get_devices()['active']}") def shutdown_event(): # Signal render thread to close on shutdown diff --git a/ui/main.py b/ui/main.py index c5a3d749..f5998622 100644 --- a/ui/main.py +++ b/ui/main.py @@ -1,12 +1,12 @@ from easydiffusion import model_manager, app, server from easydiffusion.server import server_api # required for uvicorn +server.init() + # Init the app model_manager.init() app.init() -server.init() +app.init_render_threads() # start the browser ui app.open_browser() - -app.init_render_threads()