send sync not redis

This commit is contained in:
Yuanpei-Wu 2024-08-20 15:08:33 +08:00
parent 89ee8735e0
commit da7b4fd11a

View File

@ -655,18 +655,18 @@ class PromptServer():
await send_socket_catch_exception(self.sockets[sid].send_json, message) await send_socket_catch_exception(self.sockets[sid].send_json, message)
def send_sync(self, event, data, sid=None): def send_sync(self, event, data, sid=None):
if hasattr(self, "last_prompt_id") is not True: # if hasattr(self, "last_prompt_id") is not True:
logging.warning("server has not attr last_prompt_id") # logging.warning("server has not attr last_prompt_id")
return # return
prompt_id = self.last_prompt_id # prompt_id = self.last_prompt_id
key = "comfy_response_" + prompt_id # key = "comfy_response_" + prompt_id
message = { # message = {
"type": event, # "type": event,
"data": data, # "data": data,
} # }
res = self.redis_op.zadd_with_expire(key, json.dumps(message), int(time.time()), 120) # res = self.redis_op.zadd_with_expire(key, json.dumps(message), int(time.time()), 120)
if not res: # if not res:
logging.warning(f"Failed to send {event}") # logging.warning(f"Failed to send {event}")
self.loop.call_soon_threadsafe( self.loop.call_soon_threadsafe(
self.messages.put_nowait, (event, data, sid)) self.messages.put_nowait, (event, data, sid))