Skip to content

Ignore error when trying to delete non-existing session #2

@kennu

Description

@kennu

The session backend currently dies with an exception if a session that is being deleted doesn't exist in Tokyo Tyrant any more for some reason.

Here's a patch to ignore the error:

diff --git a/tokyo_sessions/tyrant.py b/tokyo_sessions/tyrant.py
index 2152630..22cb54b 100644
--- a/tokyo_sessions/tyrant.py
+++ b/tokyo_sessions/tyrant.py
@@ -62,4 +62,8 @@ class SessionStore(SessionBase):
             if self._session_key is None:
                 return
             session_key = self._session_key
-        del get_server()[session_key]
\ No newline at end of file
+        try:
+            del get_server()[session_key]
+        except:
+            # Ignore error if session didn't exist in database any more.
+            pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions