Allow start_render_thread to proceed faster in case of failure.

This commit is contained in:
Marc-Andre Ferland 2022-10-30 06:04:06 -04:00
parent 2208545612
commit eb596ba866

View File

@ -253,8 +253,11 @@ def thread_render(device):
from . import runtime from . import runtime
try: try:
runtime.device_init(device) runtime.device_init(device)
except: except Exception as e:
print(traceback.format_exc()) print(traceback.format_exc())
weak_thread_data[threading.current_thread()] = {
'error': e
}
return return
weak_thread_data[threading.current_thread()] = { weak_thread_data[threading.current_thread()] = {
'device': runtime.thread_data.device, 'device': runtime.thread_data.device,
@ -377,8 +380,7 @@ def is_alive(name=None):
for rthread in render_threads: for rthread in render_threads:
if name is not None: if name is not None:
weak_data = weak_thread_data.get(rthread) weak_data = weak_thread_data.get(rthread)
if weak_data is None or weak_data['device'] is None: if weak_data is None or not 'device' in weak_data or weak_data['device'] is None:
print('The thread', rthread.name, 'is registered but has no data store in the task manager.')
continue continue
thread_name = str(weak_data['device']).lower() thread_name = str(weak_data['device']).lower()
if is_first_cuda_device(name): if is_first_cuda_device(name):
@ -405,6 +407,8 @@ def start_render_thread(device='auto'):
manager_lock.release() manager_lock.release()
timeout = DEVICE_START_TIMEOUT timeout = DEVICE_START_TIMEOUT
while not rthread.is_alive() or not rthread in weak_thread_data or not 'device' in weak_thread_data[rthread]: 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]:
return False
if timeout <= 0: if timeout <= 0:
return False return False
timeout -= 1 timeout -= 1