correct expired sessions collector

This commit is contained in:
Guille Gutierrez 2023-08-03 10:42:41 -04:00
parent cb9b9bb251
commit b06a1d3d53

View File

@ -23,13 +23,14 @@ def expired_sessions_collector(session_timeout_duration):
"""
while True:
if bool(sessions):
for _session in list(sessions):
print(_session)
_expire = datetime.datetime.strptime(_session['expire'], '%Y-%m-%d %H:%M:%S.%f')
for session_uuid in sessions:
print(sessions)
print(sessions[session_uuid]['expire'])
_expire = datetime.datetime.strptime(sessions[session_uuid]['expire'], '%Y-%m-%d %H:%M:%S.%f')
if _expire < datetime.datetime.now():
print("session for user: ", _session['username'], "expired.")
print("session for user: ", sessions[session_uuid]['user'], "expired.")
del sessions[session]
del sessions[session_uuid]
time.sleep(60 * int(session_timeout_duration))