Merge pull request #11923 from AnyISalIn/dev

[bug] If txt2img/img2img raises an exception, finally call state.end()
This commit is contained in:
AUTOMATIC1111 2023-07-22 07:03:21 +03:00
parent 636ff513b0
commit 704628b903

View File

@ -333,6 +333,7 @@ class Api:
p.outpath_grids = opts.outdir_txt2img_grids p.outpath_grids = opts.outdir_txt2img_grids
p.outpath_samples = opts.outdir_txt2img_samples p.outpath_samples = opts.outdir_txt2img_samples
try:
shared.state.begin(job="scripts_txt2img") shared.state.begin(job="scripts_txt2img")
if selectable_scripts is not None: if selectable_scripts is not None:
p.script_args = script_args p.script_args = script_args
@ -340,6 +341,7 @@ class Api:
else: else:
p.script_args = tuple(script_args) # Need to pass args as tuple here p.script_args = tuple(script_args) # Need to pass args as tuple here
processed = process_images(p) processed = process_images(p)
finally:
shared.state.end() shared.state.end()
b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else [] b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
@ -390,6 +392,7 @@ class Api:
p.outpath_grids = opts.outdir_img2img_grids p.outpath_grids = opts.outdir_img2img_grids
p.outpath_samples = opts.outdir_img2img_samples p.outpath_samples = opts.outdir_img2img_samples
try:
shared.state.begin(job="scripts_img2img") shared.state.begin(job="scripts_img2img")
if selectable_scripts is not None: if selectable_scripts is not None:
p.script_args = script_args p.script_args = script_args
@ -397,6 +400,7 @@ class Api:
else: else:
p.script_args = tuple(script_args) # Need to pass args as tuple here p.script_args = tuple(script_args) # Need to pass args as tuple here
processed = process_images(p) processed = process_images(p)
finally:
shared.state.end() shared.state.end()
b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else [] b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []