16 from threading
import Lock
17 from uuid
import uuid4
25 An class representing a Mycroft Session Identifier 28 def __init__(self, session_id, expiration_seconds=180):
35 update the touch_time on the session 43 determine if the session has expired 54 """ Keeps track of the current active session. """ 55 __current_session =
None 61 get the active session. 63 :return: An active session 65 config = Configuration.get().
get(
'session')
67 with SessionManager.__lock:
68 if (
not SessionManager.__current_session
or 69 SessionManager.__current_session.expired()):
70 SessionManager.__current_session =
Session(
71 str(uuid4()), expiration_seconds=config.get(
'ttl', 180))
73 "New Session Start: " +
74 SessionManager.__current_session.session_id)
75 return SessionManager.__current_session
80 Update the last_touch timestamp on the current session 84 SessionManager.get().
touch()
def __init__(self, session_id, expiration_seconds=180)