Skip to content

Commit

Permalink
Add timestamp to execution messages (comfyanonymous#4076)
Browse files Browse the repository at this point in the history
* Add timestamp to execution messages

* Add execution_end message

* Rename to execution_success
  • Loading branch information
huchenlei authored and pmason314 committed Jul 26, 2024
1 parent 05b8d7b commit d5ad3dd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import threading
import heapq
import time
import traceback
import inspect
from typing import List, Literal, NamedTuple, Optional
Expand Down Expand Up @@ -283,7 +284,11 @@ def reset(self):
self.success = True
self.old_prompt = {}

def add_message(self, event, data, broadcast: bool):
def add_message(self, event, data: dict, broadcast: bool):
data = {
**data,
"timestamp": int(time.time() * 1000),
}
self.status_messages.append((event, data))
if self.server.client_id is not None or broadcast:
self.server.send_sync(event, data, self.server.client_id)
Expand Down Expand Up @@ -394,6 +399,9 @@ def execute(self, prompt, prompt_id, extra_data={}, execute_outputs=[]):
if self.success is not True:
self.handle_execution_error(prompt_id, prompt, current_outputs, executed, error, ex)
break
else:
# Only execute when the while-loop ends without break
self.add_message("execution_success", { "prompt_id": prompt_id }, broadcast=False)

for x in executed:
self.old_prompt[x] = copy.deepcopy(prompt[x])
Expand Down

0 comments on commit d5ad3dd

Please sign in to comment.