mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
use AsyncTask for last_stop handling instead of shared
This commit is contained in:
@@ -6,6 +6,7 @@ class AsyncTask:
|
|||||||
self.args = args
|
self.args = args
|
||||||
self.yields = []
|
self.yields = []
|
||||||
self.results = []
|
self.results = []
|
||||||
|
self.last_stop = False
|
||||||
|
|
||||||
|
|
||||||
async_tasks = []
|
async_tasks = []
|
||||||
@@ -722,7 +723,7 @@ def worker():
|
|||||||
|
|
||||||
yield_result(async_task, imgs, do_not_show_finished_images=len(tasks) == 1)
|
yield_result(async_task, imgs, do_not_show_finished_images=len(tasks) == 1)
|
||||||
except fcbh.model_management.InterruptProcessingException as e:
|
except fcbh.model_management.InterruptProcessingException as e:
|
||||||
if shared.last_stop == 'skip':
|
if async_task.last_stop == 'skip':
|
||||||
print('User skipped')
|
print('User skipped')
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ from modules.private_logger import get_current_html_path
|
|||||||
from modules.ui_gradio_extensions import reload_javascript
|
from modules.ui_gradio_extensions import reload_javascript
|
||||||
from modules.auth import auth_enabled, check_auth
|
from modules.auth import auth_enabled, check_auth
|
||||||
|
|
||||||
|
currentTask = gr.State()
|
||||||
|
|
||||||
def generate_clicked(*args):
|
def generate_clicked(*args):
|
||||||
# outputs=[progress_html, progress_window, progress_gallery, gallery]
|
# outputs=[progress_html, progress_window, progress_gallery, gallery]
|
||||||
|
|
||||||
execution_start_time = time.perf_counter()
|
execution_start_time = time.perf_counter()
|
||||||
task = worker.AsyncTask(args=list(args))
|
currentTask.value = task = worker.AsyncTask(args=list(args))
|
||||||
finished = False
|
finished = False
|
||||||
|
|
||||||
yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \
|
yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \
|
||||||
@@ -117,13 +118,13 @@ with shared.gradio_root:
|
|||||||
|
|
||||||
def stop_clicked():
|
def stop_clicked():
|
||||||
import fcbh.model_management as model_management
|
import fcbh.model_management as model_management
|
||||||
shared.last_stop = 'stop'
|
currentTask.value.last_stop = 'stop'
|
||||||
model_management.interrupt_current_processing()
|
model_management.interrupt_current_processing()
|
||||||
return [gr.update(interactive=False)] * 2
|
return [gr.update(interactive=False)] * 2
|
||||||
|
|
||||||
def skip_clicked():
|
def skip_clicked():
|
||||||
import fcbh.model_management as model_management
|
import fcbh.model_management as model_management
|
||||||
shared.last_stop = 'skip'
|
currentTask.value.last_stop = 'skip'
|
||||||
model_management.interrupt_current_processing()
|
model_management.interrupt_current_processing()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user