浏览代码

Apply suggestions

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