37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""
|
|
Singleton Orchestrator Manager
|
|
Provides a single shared instance of PromptOrchestrator for all ComfyUI nodes
|
|
"""
|
|
|
|
from typing import Optional
|
|
from .orchestrator import PromptOrchestrator
|
|
|
|
|
|
# Global singleton instance
|
|
_orchestrator_instance: Optional[PromptOrchestrator] = None
|
|
|
|
|
|
def get_orchestrator() -> PromptOrchestrator:
|
|
"""
|
|
Get or create the singleton orchestrator instance.
|
|
|
|
This ensures only one PromptOrchestrator is created and shared
|
|
across all nodes, improving performance and reducing memory usage.
|
|
|
|
Returns:
|
|
PromptOrchestrator: The singleton orchestrator instance
|
|
"""
|
|
global _orchestrator_instance
|
|
if _orchestrator_instance is None:
|
|
_orchestrator_instance = PromptOrchestrator()
|
|
return _orchestrator_instance
|
|
|
|
|
|
def reset_orchestrator() -> None:
|
|
"""
|
|
Reset the singleton instance (mainly for testing purposes).
|
|
Forces creation of a new orchestrator on next get_orchestrator() call.
|
|
"""
|
|
global _orchestrator_instance
|
|
_orchestrator_instance = None
|