|
@@ -26,10 +26,11 @@ class _Reloader:
|
|
|
_lock = threading.RLock()
|
|
|
|
|
|
def __new__(cls, *args, **kwargs):
|
|
|
- if not isinstance(cls._instance, cls):
|
|
|
- cls._instance = super().__new__(cls *args, **kwargs)
|
|
|
- cls._instance._no_reload_context = False # Initialize once
|
|
|
- cls._instance._context_depth = 0 # Track nested `with` usage
|
|
|
+ with cls._lock:
|
|
|
+ if not isinstance(cls._instance, cls):
|
|
|
+ cls._instance = super().__new__(cls *args, **kwargs)
|
|
|
+ cls._instance._no_reload_context = False # Initialize once
|
|
|
+ cls._instance._context_depth = 0 # Track nested `with` usage
|
|
|
cls._managers = cls._build_managers()
|
|
|
return cls._instance
|
|
|
|