From 33a0cc2885f1d3e757ed8b6094feb8ef9eb424d6 Mon Sep 17 00:00:00 2001 From: Deep Mehta Date: Tue, 3 Mar 2026 16:27:24 -0800 Subject: [PATCH] fix: add sync get_local/set_local for graph traversal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ExecutionList in graph.py calls output_cache.get() and .set() from sync methods (is_cached, cache_link, get_cache). These cannot await the now-async get/set. Add get_local/set_local that bypass external providers and only access the local dict — which is all graph traversal needs. Co-Authored-By: Claude Opus 4.6 --- comfy_execution/caching.py | 32 ++++++++++++++++++++++++++++++++ comfy_execution/graph.py | 6 +++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/comfy_execution/caching.py b/comfy_execution/caching.py index 47681f332..b29efd04d 100644 --- a/comfy_execution/caching.py +++ b/comfy_execution/caching.py @@ -201,6 +201,21 @@ class BasicCache: def poll(self, **kwargs): pass + def get_local(self, node_id): + """Sync local-only cache lookup (no external providers).""" + if not self.initialized: + return None + cache_key = self.cache_key_set.get_data_key(node_id) + if cache_key in self.cache: + return self.cache[cache_key] + return None + + def set_local(self, node_id, value): + """Sync local-only cache store (no external providers).""" + assert self.initialized + cache_key = self.cache_key_set.get_data_key(node_id) + self.cache[cache_key] = value + async def _set_immediate(self, node_id, value): assert self.initialized cache_key = self.cache_key_set.get_data_key(node_id) @@ -387,11 +402,22 @@ class HierarchicalCache(BasicCache): return None return await cache._get_immediate(node_id) + def get_local(self, node_id): + cache = self._get_cache_for(node_id) + if cache is None: + return None + return BasicCache.get_local(cache, node_id) + async def set(self, node_id, value): cache = self._get_cache_for(node_id) assert cache is not None await cache._set_immediate(node_id, value) + def set_local(self, node_id, value): + cache = self._get_cache_for(node_id) + assert cache is not None + BasicCache.set_local(cache, node_id, value) + async def ensure_subcache_for(self, node_id, children_ids): cache = self._get_cache_for(node_id) assert cache is not None @@ -414,9 +440,15 @@ class NullCache: async def get(self, node_id): return None + def get_local(self, node_id): + return None + async def set(self, node_id, value): pass + def set_local(self, node_id, value): + pass + async def ensure_subcache_for(self, node_id, children_ids): return self diff --git a/comfy_execution/graph.py b/comfy_execution/graph.py index 9d170b16e..c47f3c79b 100644 --- a/comfy_execution/graph.py +++ b/comfy_execution/graph.py @@ -204,12 +204,12 @@ class ExecutionList(TopologicalSort): self.execution_cache_listeners = {} def is_cached(self, node_id): - return self.output_cache.get(node_id) is not None + return self.output_cache.get_local(node_id) is not None def cache_link(self, from_node_id, to_node_id): if to_node_id not in self.execution_cache: self.execution_cache[to_node_id] = {} - self.execution_cache[to_node_id][from_node_id] = self.output_cache.get(from_node_id) + self.execution_cache[to_node_id][from_node_id] = self.output_cache.get_local(from_node_id) if from_node_id not in self.execution_cache_listeners: self.execution_cache_listeners[from_node_id] = set() self.execution_cache_listeners[from_node_id].add(to_node_id) @@ -221,7 +221,7 @@ class ExecutionList(TopologicalSort): if value is None: return None #Write back to the main cache on touch. - self.output_cache.set(from_node_id, value) + self.output_cache.set_local(from_node_id, value) return value def cache_update(self, node_id, value):