Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion qwen_agent/tools/mcp_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@

class MCPManager:
_instance = None # Private class variable to store the unique instance
_lock = threading.Lock() # Lock for thread-safe singleton creation

def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super(MCPManager, cls).__new__(cls, *args, **kwargs)
with cls._lock:
# Double-checked locking: re-check after acquiring the lock
if cls._instance is None:
cls._instance = super(MCPManager, cls).__new__(cls, *args, **kwargs)
return cls._instance

def __init__(self):
Expand Down