mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-22 12:37:04 +08:00
Cache /object_info
If you have a lot of custom nodes installed, it can take a while to iterate through all of them. This takes page reload from 5s to under 1s on my machine. AFAIK new nodes are never added after startup, so the cache remains valid.
This commit is contained in:
parent
8dc19e40d1
commit
d783245e57
20
server.py
20
server.py
@ -89,6 +89,8 @@ class PromptServer():
|
||||
self.client_id = None
|
||||
|
||||
self.on_prompt_handlers = []
|
||||
self.node_info_cache = None
|
||||
|
||||
|
||||
@routes.get('/ws')
|
||||
async def websocket_handler(request):
|
||||
@ -408,14 +410,16 @@ class PromptServer():
|
||||
|
||||
@routes.get("/object_info")
|
||||
async def get_object_info(request):
|
||||
out = {}
|
||||
for x in nodes.NODE_CLASS_MAPPINGS:
|
||||
try:
|
||||
out[x] = node_info(x)
|
||||
except Exception as e:
|
||||
logging.error(f"[ERROR] An error occurred while retrieving information for the '{x}' node.")
|
||||
logging.error(traceback.format_exc())
|
||||
return web.json_response(out)
|
||||
if self.node_info_cache is None:
|
||||
self.node_info_cache = {}
|
||||
for x in nodes.NODE_CLASS_MAPPINGS:
|
||||
try:
|
||||
self.node_info_cache[x] = node_info(x)
|
||||
except Exception as e:
|
||||
logging.error(f"[ERROR] An error occurred while retrieving information for the '{x}' node.")
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
return web.json_response(self.node_info_cache)
|
||||
|
||||
@routes.get("/object_info/{node_class}")
|
||||
async def get_object_info_node(request):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user