aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Fuller <gfuller23@gmail.com>2022-10-11 19:29:38 -0700
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-12 08:30:06 +0300
commitfec2221eeaafb50afd26ba3e109bf6f928011e69 (patch)
tree896f65fb262e5cb79f653dcfc3f8315e6d3ad136
parent6ac2ec2b78bc5fabd09cb866dd9a71061d669269 (diff)
Truncate error text to fix service lockup / stall
What: * Update wrap_gradio_call to add a limit to the maximum amount of text output Why: * wrap_gradio_call currently prints out a list of the arguments provided to the failing function. * if that function is save_image, this causes the entire image to be printed to stderr * If the image is large, this can cause the service to lock up while attempting to print all the text * It is easy to generate large images using the x/y plot script * it is easy to encounter image save exceptions, including if the output directory does not exist / cannot be written to, or if the file is too big * The huge amount of log spam is confusing and not particularly helpful
-rw-r--r--modules/ui.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/ui.py b/modules/ui.py
index 1204eef7..33a49d3b 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -181,8 +181,15 @@ def wrap_gradio_call(func, extra_outputs=None):
try:
res = list(func(*args, **kwargs))
except Exception as e:
+ # When printing out our debug argument list, do not print out more than a MB of text
+ max_debug_str_len = 131072 # (1024*1024)/8
+
print("Error completing request", file=sys.stderr)
- print("Arguments:", args, kwargs, file=sys.stderr)
+ argStr = f"Arguments: {str(args)} {str(kwargs)}"
+ print(argStr[:max_debug_str_len], file=sys.stderr)
+ if len(argStr) > max_debug_str_len:
+ print(f"(Argument list truncated at {max_debug_str_len}/{len(argStr)} characters)", file=sys.stderr)
+
print(traceback.format_exc(), file=sys.stderr)
shared.state.job = ""