Skip to content

Commit a8b751f

Browse files
committed
Made manager patching robust
1 parent c8bc2dd commit a8b751f

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

comfyui_to_python_utils.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ def import_custom_nodes() -> None:
1414
creates a PromptQueue, and initializes the custom nodes.
1515
"""
1616
if has_manager:
17-
import manager_core as manager
18-
if hasattr(manager, "get_config"):
19-
print("Patching manager_core.get_config to enforce offline mode.")
20-
get_config = manager.get_config
21-
def _get_config(*args, **kwargs):
22-
config = get_config(*args, **kwargs)
23-
config["network_mode"] = "offline"
24-
return config
25-
manager.get_config = _get_config
17+
try:
18+
import manager_core as manager
19+
except ImportError:
20+
print("Could not import manager_core, proceeding without it.")
21+
return
22+
else:
23+
if hasattr(manager, "get_config"):
24+
print("Patching manager_core.get_config to enforce offline mode.")
25+
try:
26+
get_config = manager.get_config
27+
def _get_config(*args, **kwargs):
28+
config = get_config(*args, **kwargs)
29+
config["network_mode"] = "offline"
30+
return config
31+
manager.get_config = _get_config
32+
except Exception as e:
33+
print("Failed to patch manager_core.get_config:", e)
2634

2735
import asyncio
2836
import execution

0 commit comments

Comments
 (0)