fsb: Work around cookie processors no longer being pickleable. master
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 13 Nov 2020 21:19:27 +0000 (22:19 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 13 Nov 2020 21:19:27 +0000 (22:19 +0100)
fulbank/fsb.py

index 145de7b..8f6280c 100644 (file)
@@ -289,6 +289,18 @@ class session(object):
         self.logout()
         self._req("v5/framework/clientsession", method="DELETE")
 
+    def __getstate__(self):
+        state = dict(self.__dict__)
+        state["jar"] = list(state["jar"].cookiejar)
+        return state
+
+    def __setstate__(self, state):
+        jar = request.HTTPCookieProcessor()
+        for cookie in state["jar"]:
+            jar.cookiejar.set_cookie(cookie)
+        state["jar"] = jar
+        self.__dict__.update(state)
+
     def __enter__(self):
         return self