mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-26 18:25:29 +01:00
Wait until device is fully ready before proceding.
This commit is contained in:
parent
0dfaf9159d
commit
7f4786f9dd
@ -20,6 +20,8 @@ ERR_LOCK_FAILED = ' failed to acquire lock within timeout.'
|
||||
LOCK_TIMEOUT = 15 # Maximum locking time in seconds before failing a task.
|
||||
# It's better to get an exception than a deadlock... ALWAYS use timeout in critical paths.
|
||||
|
||||
DEVICE_START_TIMEOUT = 60 # seconds - Maximum time to wait for a render device to init.
|
||||
|
||||
class SymbolClass(type): # Print nicely formatted Symbol names.
|
||||
def __repr__(self): return self.__qualname__
|
||||
def __str__(self): return self.__name__
|
||||
@ -240,9 +242,6 @@ def thread_get_next_task():
|
||||
def thread_render(device):
|
||||
global current_state, current_state_error, current_model_path
|
||||
from . import runtime
|
||||
weak_thread_data[threading.current_thread()] = {
|
||||
'device': device
|
||||
}
|
||||
try:
|
||||
runtime.device_init(device)
|
||||
except:
|
||||
@ -367,8 +366,8 @@ def start_render_thread(device='auto'):
|
||||
rthread.daemon = True
|
||||
rthread.name = THREAD_NAME_PREFIX + device
|
||||
rthread.start()
|
||||
timeout = LOCK_TIMEOUT
|
||||
while not rthread.is_alive():
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user