fix session manager

This commit is contained in:
overcuriousity 2025-09-12 14:18:55 +02:00
parent 007ebbfd73
commit 8b7a0656bb

View File

@ -33,6 +33,22 @@ class SessionManager:
print(f"SessionManager initialized with Redis backend and {session_timeout_minutes}min timeout")
def __getstate__(self):
state = self.__dict__.copy()
# Exclude the unpickleable 'lock' and 'cleanup_thread' attributes
if 'lock' in state:
del state['lock']
if 'cleanup_thread' in state:
del state['cleanup_thread']
return state
def __setstate__(self, state):
self.__dict__.update(state)
# Re-initialize the 'lock' and 'cleanup_thread' attributes
self.lock = threading.Lock()
self.cleanup_thread = threading.Thread(target=self._cleanup_loop, daemon=True)
self.cleanup_thread.start()
def _get_session_key(self, session_id: str) -> str:
"""Generates the Redis key for a session."""
return f"dnsrecon:session:{session_id}"