mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-06-02 01:22:11 +08:00
Prevent custom nodes from hooking certain functions. (#7825)
This commit is contained in:
parent
ac10a0d69e
commit
542b4b36b6
17
hook_breaker_ac10a0.py
Normal file
17
hook_breaker_ac10a0.py
Normal 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])
|
5
main.py
5
main.py
@ -141,7 +141,7 @@ import nodes
|
|||||||
import comfy.model_management
|
import comfy.model_management
|
||||||
import comfyui_version
|
import comfyui_version
|
||||||
import app.logger
|
import app.logger
|
||||||
|
import hook_breaker_ac10a0
|
||||||
|
|
||||||
def cuda_malloc_warning():
|
def cuda_malloc_warning():
|
||||||
device = comfy.model_management.get_torch_device()
|
device = comfy.model_management.get_torch_device()
|
||||||
@ -215,6 +215,7 @@ def prompt_worker(q, server_instance):
|
|||||||
comfy.model_management.soft_empty_cache()
|
comfy.model_management.soft_empty_cache()
|
||||||
last_gc_collect = current_time
|
last_gc_collect = current_time
|
||||||
need_gc = False
|
need_gc = False
|
||||||
|
hook_breaker_ac10a0.restore_functions()
|
||||||
|
|
||||||
|
|
||||||
async def run(server_instance, address='', port=8188, verbose=True, call_on_start=None):
|
async def run(server_instance, address='', port=8188, verbose=True, call_on_start=None):
|
||||||
@ -268,7 +269,9 @@ def start_comfyui(asyncio_loop=None):
|
|||||||
prompt_server = server.PromptServer(asyncio_loop)
|
prompt_server = server.PromptServer(asyncio_loop)
|
||||||
q = execution.PromptQueue(prompt_server)
|
q = execution.PromptQueue(prompt_server)
|
||||||
|
|
||||||
|
hook_breaker_ac10a0.save_functions()
|
||||||
nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes)
|
nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes)
|
||||||
|
hook_breaker_ac10a0.restore_functions()
|
||||||
|
|
||||||
cuda_malloc_warning()
|
cuda_malloc_warning()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user