Refactor worker monitor placement and remove legacy init patch

This commit is contained in:
Robert Wojciechowski
2026-02-23 05:23:25 +00:00
parent c1010dcd3c
commit e950335577
3 changed files with 8 additions and 42 deletions
-36
View File
@@ -1,39 +1,3 @@
import os
import sys
# Add the directory to Python path
sys.path.append(os.path.dirname(__file__))
# Patch ComfyUI execution validation for DistributedVideoCollector
try:
import execution
from .distributed import ImageBatchDivider
# Store original validate function if it exists
if hasattr(execution, 'validate_outputs'):
original_validate_outputs = execution.validate_outputs
def patched_validate_outputs(executor, node_id, result, node_class):
if node_class == ImageBatchDivider:
return # Skip validation for our dynamic output node
return original_validate_outputs(executor, node_id, result, node_class)
execution.validate_outputs = patched_validate_outputs
else:
# Fallback: patch the main execute method if validate_outputs doesn't exist
if hasattr(execution.PromptExecutor, 'execute'):
original_execute = execution.PromptExecutor.execute
def patched_execute(self, prompt, prompt_id, extra_data={}, execute_outputs=[]):
# This is a more complex patch - for now just call original
# The ByPassTypeTuple should handle most validation issues
return original_execute(self, prompt, prompt_id, extra_data, execute_outputs)
execution.PromptExecutor.execute = patched_execute
except ImportError:
pass # ComfyUI execution module not available during import
# Import everything needed from the main module
from .distributed import (
NODE_CLASS_MAPPINGS as DISTRIBUTED_CLASS_MAPPINGS,
+1 -1
View File
@@ -220,7 +220,7 @@ class WorkerProcessManager:
# Wrap command with monitor if needed
if stop_on_master_exit and env.get('COMFYUI_MASTER_PID'):
# Use the monitor wrapper
monitor_script = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'worker_monitor.py')
monitor_script = os.path.join(os.path.dirname(__file__), 'worker_monitor.py')
monitored_cmd = [get_python_executable(), monitor_script] + cmd
log_handle.write(f"[Worker Monitor] Monitoring master PID: {env['COMFYUI_MASTER_PID']}\n")
log_handle.flush()
@@ -10,12 +10,14 @@ import subprocess
import platform
import signal
# Add parent directory to path to import utils
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Add package root to path so this script works when launched by file path.
NODE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if NODE_ROOT not in sys.path:
sys.path.insert(0, NODE_ROOT)
try:
from ComfyUI_Distributed.utils.process import is_process_alive, terminate_process
from ComfyUI_Distributed.utils.constants import WORKER_CHECK_INTERVAL, PROCESS_TERMINATION_TIMEOUT
from utils.process import is_process_alive, terminate_process
from utils.constants import WORKER_CHECK_INTERVAL, PROCESS_TERMINATION_TIMEOUT
except ImportError:
# Fallback if running from different context
def is_process_alive(pid):
@@ -127,4 +129,4 @@ if __name__ == "__main__":
command = sys.argv[1:]
# Start monitoring
monitor_and_run(master_pid, command)
monitor_and_run(master_pid, command)