Skip to content

Commit

Permalink
Fixing redissession
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbyt3r committed May 2, 2024
1 parent 92370b3 commit 71c842e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sideboard/lib/_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
except ImportError:
from cherrypy.lib.sessions import Session
import redis
import pickle
from redis import Sentinel

class RedisSession(Session):
Expand Down Expand Up @@ -62,15 +63,16 @@ def _exists(self):

def _load(self):
try:
return pickle.loads(self.cache.get(self.prefix+self.id))
return pickle.loads(self.cache.get(self.prefix+self.id))
except TypeError:
# if id not defined pickle can't load None and raise TypeError
return None
return None

def _save(self, expiration_time):
pickled_data = pickle.dumps(
(self._data, expiration_time),
pickle.HIGHEST_PROTOCOL)
pickle.HIGHEST_PROTOCOL
)

result = self.cache.setex(self.prefix+self.id, self.timeout * 60, pickled_data)

Expand Down

0 comments on commit 71c842e

Please sign in to comment.