From 9f2ae494839b5b64455f2df731c5fb2f3dda22ad Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Tue, 14 Apr 2020 11:28:43 +0200 Subject: [PATCH] Fix improper cleanup of sessions --- shittyserver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shittyserver.py b/shittyserver.py index c31cfd8..882329f 100644 --- a/shittyserver.py +++ b/shittyserver.py @@ -150,7 +150,11 @@ class Session(object): print(self.connection_id, "Deactivating") self.running = False if self.websocket is not None: - await self.websocket.send(json.dumps({"kind": "DEACTIVATED"})) + try: + await self.websocket.send(json.dumps({"kind": "DEACTIVATED"})) + except websockets.exceptions.ConnectionClosedError: + print(self.connection_id, "not sending DEACTIVATED as it's already closed") + pass async def end(self) -> None: global active_sessions, live_session