fix: TaskManager accepts max_workers argument in __new__
- Updated TaskManager.__new__ to accept max_workers parameter - Fixed get_task_manager to return TaskManager._instance directly - This fixes the initialization error: 'TaskManager.new() got an unexpected keyword argument'
This commit is contained in:
parent
80a92aa1ee
commit
01b001aa88
|
|
@ -78,12 +78,13 @@ class TaskManager:
|
||||||
_instance = None
|
_instance = None
|
||||||
_lock = threading.Lock()
|
_lock = threading.Lock()
|
||||||
|
|
||||||
def __new__(cls):
|
def __new__(cls, max_workers: int = 4):
|
||||||
if cls._instance is None:
|
if cls._instance is None:
|
||||||
with cls._lock:
|
with cls._lock:
|
||||||
if cls._instance is None:
|
if cls._instance is None:
|
||||||
cls._instance = super().__new__(cls)
|
cls._instance = super().__new__(cls)
|
||||||
cls._instance._initialized = False
|
cls._instance._initialized = False
|
||||||
|
cls._instance._max_workers = max_workers
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def __init__(self, max_workers: int = 4):
|
def __init__(self, max_workers: int = 4):
|
||||||
|
|
@ -354,4 +355,4 @@ def get_task_manager(max_workers: int = 4) -> TaskManager:
|
||||||
# Create with specified max_workers if not already created
|
# Create with specified max_workers if not already created
|
||||||
if TaskManager._instance is None:
|
if TaskManager._instance is None:
|
||||||
TaskManager(max_workers=max_workers)
|
TaskManager(max_workers=max_workers)
|
||||||
return TaskManager()
|
return TaskManager._instance
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue