1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-02 15:04:50 +08:00

Prevent custom nodes from hooking certain functions. (#7825)

This commit is contained in:
comfyanonymous
2025-04-26 17:52:56 -07:00
committed by GitHub
parent ac10a0d69e
commit 542b4b36b6
2 changed files with 21 additions and 1 deletions

17
hook_breaker_ac10a0.py Normal file
View File

@@ -0,0 +1,17 @@
# Prevent custom nodes from hooking anything important
import comfy.model_management
HOOK_BREAK = [(comfy.model_management, "cast_to")]
SAVED_FUNCTIONS = []
def save_functions():
for f in HOOK_BREAK:
SAVED_FUNCTIONS.append((f[0], f[1], getattr(f[0], f[1])))
def restore_functions():
for f in SAVED_FUNCTIONS:
setattr(f[0], f[1], f[2])