aboutsummaryrefslogtreecommitdiff
path: root/modules/call_queue.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-01-15 18:50:56 +0300
committerAUTOMATIC <16777216c@gmail.com>2023-01-15 18:51:04 +0300
commitd8b90ac121cbf0c18b1dc9d56a5e1d14ca51e74e (patch)
tree0b204c9db8ee98972adbc2619a41c7f508369031 /modules/call_queue.py
parentebfdd7baeb660ec66f78e1a0e5e45442025f262d (diff)
big rework of progressbar/preview system to allow multiple users to prompts at the same time and do not get previews of each other
Diffstat (limited to 'modules/call_queue.py')
-rw-r--r--modules/call_queue.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/modules/call_queue.py b/modules/call_queue.py
index 4cd49533..92097c15 100644
--- a/modules/call_queue.py
+++ b/modules/call_queue.py
@@ -4,7 +4,7 @@ import threading
import traceback
import time
-from modules import shared
+from modules import shared, progress
queue_lock = threading.Lock()
@@ -22,12 +22,23 @@ def wrap_queued_call(func):
def wrap_gradio_gpu_call(func, extra_outputs=None):
def f(*args, **kwargs):
- shared.state.begin()
+ # if the first argument is a string that says "task(...)", it is treated as a job id
+ if len(args) > 0 and type(args[0]) == str and args[0][0:5] == "task(" and args[0][-1] == ")":
+ id_task = args[0]
+ progress.add_task_to_queue(id_task)
+ else:
+ id_task = None
with queue_lock:
- res = func(*args, **kwargs)
+ shared.state.begin()
+ progress.start_task(id_task)
+
+ try:
+ res = func(*args, **kwargs)
+ finally:
+ progress.finish_task(id_task)
- shared.state.end()
+ shared.state.end()
return res