Commit e0b58527 authored by siutin's avatar siutin

use condition to wait for result

parent 4242e194
...@@ -7,7 +7,7 @@ import time ...@@ -7,7 +7,7 @@ import time
from modules import shared, progress from modules import shared, progress
queue_lock = threading.Lock() queue_lock = threading.Lock()
queue_lock_condition = threading.Condition(lock=queue_lock)
def wrap_queued_call(func): def wrap_queued_call(func):
def f(*args, **kwargs): def f(*args, **kwargs):
......
...@@ -6,6 +6,7 @@ import gradio as gr ...@@ -6,6 +6,7 @@ import gradio as gr
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from typing import List from typing import List
from modules import call_queue
from modules.shared import opts from modules.shared import opts
import modules.shared as shared import modules.shared as shared
...@@ -57,8 +58,9 @@ def restore_progress_call(task_tag): ...@@ -57,8 +58,9 @@ def restore_progress_call(task_tag):
else: else:
t_task = current_task t_task = current_task
while t_task != last_task_id: with call_queue.queue_lock_condition:
time.sleep(2.5) call_queue.queue_lock_condition.wait_for(lambda: t_task == last_task_id)
return last_task_result return last_task_result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment