Browse Source

fix mutable default in EventNamespace (#4420)

Thomas Brandého 5 tháng trước cách đây
mục cha
commit
697e26c25b
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      reflex/app.py

+ 4 - 2
reflex/app.py

@@ -1462,10 +1462,10 @@ class EventNamespace(AsyncNamespace):
     app: App
     app: App
 
 
     # Keep a mapping between socket ID and client token.
     # Keep a mapping between socket ID and client token.
-    token_to_sid: dict[str, str] = {}
+    token_to_sid: dict[str, str]
 
 
     # Keep a mapping between client token and socket ID.
     # Keep a mapping between client token and socket ID.
-    sid_to_token: dict[str, str] = {}
+    sid_to_token: dict[str, str]
 
 
     def __init__(self, namespace: str, app: App):
     def __init__(self, namespace: str, app: App):
         """Initialize the event namespace.
         """Initialize the event namespace.
@@ -1475,6 +1475,8 @@ class EventNamespace(AsyncNamespace):
             app: The application object.
             app: The application object.
         """
         """
         super().__init__(namespace)
         super().__init__(namespace)
+        self.token_to_sid = {}
+        self.sid_to_token = {}
         self.app = app
         self.app = app
 
 
     def on_connect(self, sid, environ):
     def on_connect(self, sid, environ):