1
0
benedikt-bartscher 5 сар өмнө
parent
commit
ea90a3ebfa
1 өөрчлөгдсөн 14 нэмэгдсэн , 2 устгасан
  1. 14 2
      reflex/state.py

+ 14 - 2
reflex/state.py

@@ -2122,14 +2122,26 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
             state["__dict__"].pop("router", None)
             state["__dict__"].pop("router", None)
             state["__dict__"].pop("router_data", None)
             state["__dict__"].pop("router_data", None)
         # Never serialize parent_state or substates.
         # Never serialize parent_state or substates.
-        state["__dict__"]["parent_state"] = None
-        state["__dict__"]["substates"] = {}
+        state["__dict__"].pop("parent_state", None)
+        state["__dict__"].pop("substates", None)
         state["__dict__"].pop("_was_touched", None)
         state["__dict__"].pop("_was_touched", None)
         # Remove all inherited vars.
         # Remove all inherited vars.
         for inherited_var_name in self.inherited_vars:
         for inherited_var_name in self.inherited_vars:
             state["__dict__"].pop(inherited_var_name, None)
             state["__dict__"].pop(inherited_var_name, None)
         return state
         return state
 
 
+    def __setstate__(self, state: dict[str, Any]):
+        """Set the state from redis deserialization.
+
+        This method is called by pickle to deserialize the object.
+
+        Args:
+            state: The state dict for deserialization.
+        """
+        state["__dict__"]["parent_state"] = None
+        state["__dict__"]["substates"] = {}
+        super().__setstate__(state)
+
     def _check_state_size(
     def _check_state_size(
         self,
         self,
         pickle_state_size: int,
         pickle_state_size: int,