completely solve 'NoneType' object is not iterable

This commit is contained in:
layerdiffusion
2024-08-13 15:36:18 -07:00
parent a0849953bd
commit bb58520a4c
2 changed files with 22 additions and 14 deletions

View File

@@ -2,7 +2,9 @@ import os.path
from functools import wraps
import html
import time
import traceback
from modules_forge import main_thread
from modules import shared, progress, errors, devices, fifo_lock, profiling
queue_lock = fifo_lock.FIFOLock()
@@ -73,14 +75,11 @@ def wrap_gradio_call_no_job(func, extra_outputs=None, add_stats=False):
try:
res = list(func(*args, **kwargs))
except Exception as e:
# When printing out our debug argument list,
# do not print out more than a 100 KB of text
max_debug_str_len = 131072
message = "Error completing request"
arg_str = f"Arguments: {args} {kwargs}"[:max_debug_str_len]
if len(arg_str) > max_debug_str_len:
arg_str += f" (Argument list truncated at {max_debug_str_len}/{len(arg_str)} characters)"
errors.report(f"{message}\n{arg_str}", exc_info=True)
if main_thread.last_exception is not None:
e = main_thread.last_exception
else:
traceback.print_exc()
print(e)
if extra_outputs_array is None:
extra_outputs_array = [None, '']

View File

@@ -12,6 +12,7 @@ lock = threading.Lock()
last_id = 0
waiting_list = []
finished_list = []
last_exception = None
class Task:
@@ -21,9 +22,19 @@ class Task:
self.args = args
self.kwargs = kwargs
self.result = None
self.exception = None
def work(self):
self.result = self.func(*self.args, **self.kwargs)
global last_exception
self.exception = None
last_exception = None
try:
self.result = self.func(*self.args, **self.kwargs)
except Exception as e:
traceback.print_exc()
print(e)
self.exception = e
last_exception = e
def loop():
@@ -33,11 +44,9 @@ def loop():
if len(waiting_list) > 0:
with lock:
task = waiting_list.pop(0)
try:
task.work()
except Exception as e:
traceback.print_exc()
print(e)
task.work()
with lock:
finished_list.append(task)