mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-13 02:26:59 +08:00
only cache object_info for now
This commit is contained in:
parent
a5c50253b2
commit
cd71722b11
@ -52,12 +52,16 @@ class CacheHelper:
|
||||
"""
|
||||
def __init__(self):
|
||||
self.cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
|
||||
self.active = False
|
||||
|
||||
def get(self, key: str, default=None) -> tuple[list[str], dict[str, float], float]:
|
||||
if not self.active:
|
||||
return default
|
||||
return self.cache.get(key, default)
|
||||
|
||||
def set(self, key: str, value: tuple[list[str], dict[str, float], float]) -> None:
|
||||
self.cache[key] = value
|
||||
if self.active:
|
||||
self.cache[key] = value
|
||||
|
||||
def clear(self):
|
||||
self.cache.clear()
|
||||
|
||||
@ -553,6 +553,7 @@ class PromptServer():
|
||||
@routes.get("/object_info")
|
||||
async def get_object_info(request):
|
||||
folder_paths.cache_helper.clear()
|
||||
folder_paths.cache_helper.active = True
|
||||
out = {}
|
||||
for x in nodes.NODE_CLASS_MAPPINGS:
|
||||
try:
|
||||
@ -560,6 +561,7 @@ class PromptServer():
|
||||
except Exception as e:
|
||||
logging.error(f"[ERROR] An error occurred while retrieving information for the '{x}' node.")
|
||||
logging.error(traceback.format_exc())
|
||||
folder_paths.cache_helper.active = False
|
||||
return web.json_response(out)
|
||||
|
||||
@routes.get("/object_info/{node_class}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user