From 28b1cc7937d4c9fc2b10839962839cd735fb3eec Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 11 Jun 2020 20:36:12 +0100 Subject: [PATCH] Move peer connection status check into `_client_disconnected` --- houdini/spheniscidae.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/houdini/spheniscidae.py b/houdini/spheniscidae.py index ae7d27d..97d26c0 100644 --- a/houdini/spheniscidae.py +++ b/houdini/spheniscidae.py @@ -146,10 +146,11 @@ class Spheniscidae: await self.server.dummy_event_listeners.fire('connected', self) async def _client_disconnected(self): - del self.server.peers_by_ip[self.peer_name] - self.logger.info(f'Client {self.peer_name} disconnected') + if self.peer_name in self.server.peers_by_ip: + del self.server.peers_by_ip[self.peer_name] + self.logger.info(f'Client {self.peer_name} disconnected') - await self.server.dummy_event_listeners.fire('disconnected', self) + await self.server.dummy_event_listeners.fire('disconnected', self) async def __data_received(self, data): data = data.decode()[:-1] @@ -183,8 +184,7 @@ class Spheniscidae: except BaseException as e: self.logger.exception(e.__traceback__) - if self.peer_name in self.server.peers_by_ip: - await self._client_disconnected() + await self._client_disconnected() def __repr__(self): return f''