Skip to content

Commit

Permalink
include prompt_id in queue remaining msg
Browse files Browse the repository at this point in the history
  • Loading branch information
KubaBir committed Mar 27, 2024
1 parent 7f780e8 commit 4071169
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,17 +810,21 @@ def get_queue_position_per_client(self):
pending_clients = []
with self.mutex:
for item in self.queue:
pending_clients.append([item[3]['client_id'], item[0]])
print(item)
pending_clients.append(
[item[3]['client_id'], item[0], item[1]])
# [client_id, numer_in_queue, prompt_id]

pending_clients.sort(key=lambda i: i[1])

positions = dict()
for index, item in enumerate(pending_clients):
if item[0] not in positions:
positions[item[0]] = [index + 1]
positions[item[0]] = [[index + 1, item[2]]]
else:
positions[item[0]].append(index + 1)
positions[item[0]].append([index + 1, item[2]])

# client_id: [[number_in_queue, prompt_id], ...]
return positions

def wipe_queue(self):
Expand Down
3 changes: 2 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ def queue_updated(self):
return

for sid, positions in pending_clients.items():
self.send_sync("queue", {"remaining": positions[0]}, sid)
self.send_sync(
"queue", {"remaining": positions[0][0], "prompt_id": positions[0][1]}, sid)

async def publish_loop(self):
while True:
Expand Down

0 comments on commit 4071169

Please sign in to comment.