aboutsummaryrefslogtreecommitdiff
path: root/session.py
diff options
context:
space:
mode:
authorJonathan Weth <git@jonathanweth.de>2020-07-23 14:41:55 +0200
committerJonathan Weth <git@jonathanweth.de>2020-07-23 14:41:55 +0200
commit81e570931adc37054460e3f05d0325888050e386 (patch)
tree5f76ca768d8cbf647bc232d08350f9fc3ab3911d /session.py
parentda6b2bb9d46d096783e12553ba458eb6f3b13e32 (diff)
downloadRWA.Support.SessionService-81e570931adc37054460e3f05d0325888050e386.tar.gz
RWA.Support.SessionService-81e570931adc37054460e3f05d0325888050e386.tar.bz2
RWA.Support.SessionService-81e570931adc37054460e3f05d0325888050e386.zip
Implement bi-directional stopping of sessions
Diffstat (limited to 'session.py')
-rw-r--r--session.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/session.py b/session.py
index a6c27c5..40a091f 100644
--- a/session.py
+++ b/session.py
@@ -152,7 +152,12 @@ class Session:
r = requests.get(
STATUS_URL, params={"id": self.session_id}, headers=self._api_headers
)
- self.status_text = r.json()["status"]
+
+ if r.status_code in (401, 402, 403, 404, 405):
+ # Session doesn't exist anymore, so stop it local
+ self.stop(triggered=True)
+ else:
+ self.status_text = r.json()["status"]
def push(self):
"""Update status: Push status to Django."""
@@ -195,6 +200,8 @@ class Session:
STOP_URL, params={"id": self.session_id}, headers=self._api_headers
)
+ self.status_text = "stopped"
+
# Delete self
del self