Michael Hu commited on
Commit
b428abb
·
1 Parent(s): 00156ab

attempt fix

Browse files
src/infrastructure/config/dependency_container.py CHANGED
@@ -3,7 +3,7 @@
3
  import logging
4
  from typing import Dict, Any, Optional, TypeVar, Type, Callable, Union
5
  from enum import Enum
6
- from threading import Lock
7
  import weakref
8
 
9
  from .app_config import AppConfig
@@ -66,7 +66,7 @@ class DependencyContainer:
66
  self._services: Dict[Type, ServiceDescriptor] = {}
67
  self._singletons: Dict[Type, Any] = {}
68
  self._scoped_instances: Dict[Type, Any] = {}
69
- self._lock = Lock()
70
 
71
  # Provider factories
72
  self._tts_factory: Optional[TTSProviderFactory] = None
@@ -479,7 +479,7 @@ class DependencyScope:
479
  """
480
  self._parent = parent_container
481
  self._scoped_instances: Dict[Type, Any] = {}
482
- self._lock = Lock()
483
 
484
  def resolve(self, service_type: Type[T]) -> T:
485
  """
@@ -524,7 +524,7 @@ class DependencyScope:
524
 
525
  # Global container instance
526
  _global_container: Optional[DependencyContainer] = None
527
- _container_lock = Lock()
528
 
529
 
530
  def get_container() -> DependencyContainer:
 
3
  import logging
4
  from typing import Dict, Any, Optional, TypeVar, Type, Callable, Union
5
  from enum import Enum
6
+ from threading import RLock
7
  import weakref
8
 
9
  from .app_config import AppConfig
 
66
  self._services: Dict[Type, ServiceDescriptor] = {}
67
  self._singletons: Dict[Type, Any] = {}
68
  self._scoped_instances: Dict[Type, Any] = {}
69
+ self._lock = RLock() # Use RLock for re-entrant locking
70
 
71
  # Provider factories
72
  self._tts_factory: Optional[TTSProviderFactory] = None
 
479
  """
480
  self._parent = parent_container
481
  self._scoped_instances: Dict[Type, Any] = {}
482
+ self._lock = RLock() # Use RLock for re-entrant locking
483
 
484
  def resolve(self, service_type: Type[T]) -> T:
485
  """
 
524
 
525
  # Global container instance
526
  _global_container: Optional[DependencyContainer] = None
527
+ _container_lock = RLock() # Use RLock for re-entrant locking
528
 
529
 
530
  def get_container() -> DependencyContainer: