comparison src/memory/memory.py @ 1213:b5928601d7aa

memory: handle the case where an existing session ID is re-used for creating a new session
author souliane <souliane@mailoo.org>
date Mon, 22 Sep 2014 20:26:40 +0200
parents 628e320eab1f
children ed3b01ed70d7
comparison
equal deleted inserted replaced
1212:628e320eab1f 1213:b5928601d7aa
55 and profileGet must be used instead of __getitem__ 55 and profileGet must be used instead of __getitem__
56 @return: session_id, session_data 56 @return: session_id, session_data
57 """ 57 """
58 if session_id is None: 58 if session_id is None:
59 session_id = str(uuid4()) 59 session_id = str(uuid4())
60 elif session_id in self._sessions:
61 self._sessions[session_id][0].cancel()
62 log.warning("Session [{id}] is going to be re-initialised".format(id=session_id))
60 timer = reactor.callLater(self.timeout, self._purgeSession, session_id) 63 timer = reactor.callLater(self.timeout, self._purgeSession, session_id)
61 if session_data is None: 64 if session_data is None:
62 session_data = {} 65 session_data = {}
63 self._sessions[session_id] = (timer, session_data) if profile is None else (timer, session_data, profile) 66 self._sessions[session_id] = (timer, session_data) if profile is None else (timer, session_data, profile)
64 return session_id, session_data 67 return session_id, session_data