fix(control): ensure state cleanup runs reliably

Fix control tab getting stuck in running state
after generation completes.
This commit is contained in:
CalamitousFelicitousness
2026-01-10 02:35:04 +00:00
parent e4e863fd6d
commit 2fd52ae230
2 changed files with 5 additions and 5 deletions
-2
View File
@@ -679,7 +679,5 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg
if len(info_txt) > 0:
html_txt = html_txt + infotext_to_html(info_txt[0])
if is_generator:
jobid = shared.state.begin('UI')
yield (output_images, blended_image, html_txt, output_filename)
shared.state.end(jobid)
return (output_images, blended_image, html_txt, output_filename)
+5 -3
View File
@@ -103,12 +103,15 @@ def generate_click(job_id: str, state: str, active_tab: str, *args):
for results in control_run(state, units, helpers.input_source, helpers.input_init, helpers.input_mask, active_tab, True, *args):
progress.record_results(job_id, results)
yield return_controls(results, t)
except GeneratorExit:
pass # Generator was closed by client - cleanup will run in finally
except Exception as e:
shared.log.error(f"Control exception: {e}")
errors.display(e, 'Control')
yield [None, None, None, None, f'Control: Exception: {e}', '']
progress.finish_task(job_id)
shared.state.end(jobid)
finally:
progress.finish_task(job_id)
shared.state.end(jobid)
def create_ui(_blocks: gr.Blocks=None):
@@ -266,7 +269,6 @@ def create_ui(_blocks: gr.Blocks=None):
prompt.submit(**select_dict)
negative.submit(**select_dict)
btn_generate.click(**select_dict)
for ctrl in [input_image, input_video, input_batch, input_folder, init_image, init_video, init_batch, init_folder, tab_image, tab_video, tab_batch, tab_folder, tab_image_init, tab_video_init, tab_batch_init, tab_folder_init]:
if hasattr(ctrl, 'change'):
ctrl.change(**select_dict)