feat: replace threading.Lock() to FIFOLock

Signed-off-by: AnyISalIn <anyisalin@gmail.com>
This commit is contained in:
AnyISalIn
2023-08-21 17:48:56 +08:00
parent 42b72fe246
commit 71a0f6ef85
3 changed files with 45 additions and 4 deletions

View File

@@ -72,7 +72,12 @@ def progressapi(req: ProgressRequest):
completed = req.id_task in finished_tasks
if not active:
return ProgressResponse(active=active, queued=queued, completed=completed, id_live_preview=-1, textinfo="In queue..." if queued else "Waiting...")
textinfo = "Waiting..."
if queued:
sorted_queued = sorted(pending_tasks.keys(), key=lambda x: pending_tasks[x])
queue_index = sorted_queued.index(req.id_task)
textinfo = "In queue: {}/{}".format(queue_index + 1, len(sorted_queued))
return ProgressResponse(active=active, queued=queued, completed=completed, id_live_preview=-1, textinfo=textinfo)
progress = 0