Return the session or ``None`` if not found / expired.
(self, session_id: str)
| 102 | return state |
| 103 | |
| 104 | def get(self, session_id: str) -> Optional[SessionState]: |
| 105 | """Return the session or ``None`` if not found / expired.""" |
| 106 | with self._lock: |
| 107 | state = self._sessions.get(session_id) |
| 108 | if state is None: |
| 109 | return None |
| 110 | if state.is_expired: |
| 111 | if state.workspace is not None: |
| 112 | state.workspace.cleanup() |
| 113 | del self._sessions[session_id] |
| 114 | return None |
| 115 | state.touch() |
| 116 | return state |
| 117 | |
| 118 | def remove(self, session_id: str) -> bool: |
| 119 | """Remove a session. Returns True if it existed.""" |