jean-robin medori 5 днів тому
батько
коміт
b6d78fa93b
1 змінених файлів з 5 додано та 4 видалено
  1. 5 4
      taipy/core/_entity/_reload.py

+ 5 - 4
taipy/core/_entity/_reload.py

@@ -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