use condition to wait for result

This commit is contained in:
siutin 2023-02-06 15:57:26 +08:00
parent 4242e194e4
commit e0b58527ff
2 changed files with 5 additions and 3 deletions

View File

@ -7,7 +7,7 @@ import time
from modules import shared, progress
queue_lock = threading.Lock()
queue_lock_condition = threading.Condition(lock=queue_lock)
def wrap_queued_call(func):
def f(*args, **kwargs):

View File

@ -6,6 +6,7 @@ import gradio as gr
from pydantic import BaseModel, Field
from typing import List
from modules import call_queue
from modules.shared import opts
import modules.shared as shared
@ -57,8 +58,9 @@ def restore_progress_call(task_tag):
else:
t_task = current_task
while t_task != last_task_id:
time.sleep(2.5)
with call_queue.queue_lock_condition:
call_queue.queue_lock_condition.wait_for(lambda: t_task == last_task_id)
return last_task_result