From 726804ca63b5ad5fa5223e232e28ae5f19f9ef83 Mon Sep 17 00:00:00 2001 From: doctorpangloss <@hiddenswitch.com> Date: Tue, 26 Aug 2025 16:55:41 -0700 Subject: [PATCH] Improve the way the execution context is initialized --- comfy/execution_context.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/comfy/execution_context.py b/comfy/execution_context.py index 30ebd4894..bfd34d5ea 100644 --- a/comfy/execution_context.py +++ b/comfy/execution_context.py @@ -12,10 +12,6 @@ from .distributed.server_stub import ServerStub from .nodes.package_typing import ExportedNodes, exported_nodes_view from .progress_types import AbstractProgressRegistry, ProgressRegistryStub -comfyui_execution_context: Final[ContextVar] = ContextVar("comfyui_execution_context") -# enables context var propagation across process boundaries for process pool executors -cvpickle.register_contextvar(comfyui_execution_context, __name__) - @dataclass(frozen=True) class ExecutionContext: @@ -38,7 +34,9 @@ class ExecutionContext: yield self.list_index -comfyui_execution_context.set(ExecutionContext(server=ServerStub(), folder_names_and_paths=FolderNames(is_root=True), custom_nodes=ExportedNodes(), progress_registry=ProgressRegistryStub())) +comfyui_execution_context: Final[ContextVar] = ContextVar("comfyui_execution_context", default=ExecutionContext(server=ServerStub(), folder_names_and_paths=FolderNames(is_root=True), custom_nodes=ExportedNodes(), progress_registry=ProgressRegistryStub())) +# enables context var propagation across process boundaries for process pool executors +cvpickle.register_contextvar(comfyui_execution_context, __name__) def current_execution_context() -> ExecutionContext: