mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-11 12:17:45 +08:00
fix: inline registration logic in Caching class
Follow the Execution/NodeReplacement pattern — the public API methods contain the actual logic operating on cache_provider module state, not wrapper functions delegating to free functions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1e971fdc87
commit
2c34c89265
@ -90,14 +90,26 @@ class ComfyAPI_latest(ComfyAPIBase):
|
||||
from ._caching import CacheProvider, CacheContext, CacheValue
|
||||
|
||||
async def register_provider(self, provider: "ComfyAPI_latest.Caching.CacheProvider") -> None:
|
||||
"""Register an external cache provider."""
|
||||
from comfy_execution.cache_provider import register_cache_provider
|
||||
register_cache_provider(provider)
|
||||
"""Register an external cache provider. Providers are called in registration order."""
|
||||
from comfy_execution import cache_provider as _cp
|
||||
with _cp._providers_lock:
|
||||
if provider in _cp._providers:
|
||||
_cp._logger.warning(f"Provider {provider.__class__.__name__} already registered")
|
||||
return
|
||||
_cp._providers.append(provider)
|
||||
_cp._providers_snapshot = tuple(_cp._providers)
|
||||
_cp._logger.debug(f"Registered cache provider: {provider.__class__.__name__}")
|
||||
|
||||
async def unregister_provider(self, provider: "ComfyAPI_latest.Caching.CacheProvider") -> None:
|
||||
"""Unregister an external cache provider."""
|
||||
from comfy_execution.cache_provider import unregister_cache_provider
|
||||
unregister_cache_provider(provider)
|
||||
"""Unregister a previously registered cache provider."""
|
||||
from comfy_execution import cache_provider as _cp
|
||||
with _cp._providers_lock:
|
||||
try:
|
||||
_cp._providers.remove(provider)
|
||||
_cp._providers_snapshot = tuple(_cp._providers)
|
||||
_cp._logger.debug(f"Unregistered cache provider: {provider.__class__.__name__}")
|
||||
except ValueError:
|
||||
_cp._logger.warning(f"Provider {provider.__class__.__name__} was not registered")
|
||||
|
||||
class ComfyExtension(ABC):
|
||||
async def on_load(self) -> None:
|
||||
@ -155,15 +167,27 @@ class Caching:
|
||||
|
||||
@staticmethod
|
||||
def register_provider(provider: "Caching.CacheProvider") -> None:
|
||||
"""Register an external cache provider."""
|
||||
from comfy_execution.cache_provider import register_cache_provider
|
||||
register_cache_provider(provider)
|
||||
"""Register an external cache provider. Providers are called in registration order."""
|
||||
from comfy_execution import cache_provider as _cp
|
||||
with _cp._providers_lock:
|
||||
if provider in _cp._providers:
|
||||
_cp._logger.warning(f"Provider {provider.__class__.__name__} already registered")
|
||||
return
|
||||
_cp._providers.append(provider)
|
||||
_cp._providers_snapshot = tuple(_cp._providers)
|
||||
_cp._logger.debug(f"Registered cache provider: {provider.__class__.__name__}")
|
||||
|
||||
@staticmethod
|
||||
def unregister_provider(provider: "Caching.CacheProvider") -> None:
|
||||
"""Unregister an external cache provider."""
|
||||
from comfy_execution.cache_provider import unregister_cache_provider
|
||||
unregister_cache_provider(provider)
|
||||
"""Unregister a previously registered cache provider."""
|
||||
from comfy_execution import cache_provider as _cp
|
||||
with _cp._providers_lock:
|
||||
try:
|
||||
_cp._providers.remove(provider)
|
||||
_cp._providers_snapshot = tuple(_cp._providers)
|
||||
_cp._logger.debug(f"Unregistered cache provider: {provider.__class__.__name__}")
|
||||
except ValueError:
|
||||
_cp._logger.warning(f"Provider {provider.__class__.__name__} was not registered")
|
||||
|
||||
|
||||
ComfyAPI = ComfyAPI_latest
|
||||
|
||||
Loading…
Reference in New Issue
Block a user