From c69c019c8b83ebdac0b51e5aa197d63f7ac22727 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Wed, 6 Sep 2023 00:47:23 +0100 Subject: [PATCH] Fix TimeoutError Bug Handle all OSError exceptions rather than just ConnectionError. Allowing the to reset itself rather than fail in certain cases. --- aptbot/bot.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aptbot/bot.py b/aptbot/bot.py index 1ef4b47..eccf108 100644 --- a/aptbot/bot.py +++ b/aptbot/bot.py @@ -216,7 +216,7 @@ class Bot(ABCBot): def _receive_messages(self) -> bytes: try: data = self._irc.recv(self._BYTE_READ) - except ConnectionError as e: + except OSError as e: logger.exception(e) self._restart_connection() return b"" @@ -236,7 +236,6 @@ class Bot(ABCBot): message += data if self._AUTH_SUCC % {b"nick": self._nick} in message: logger.info("Connection with %s authenticated", self._nick) - self.disconnect() return True elif self._AUTH_BAD_FORMAT in message: logger.critical( @@ -253,7 +252,7 @@ class Bot(ABCBot): logger.critical("Connection with %s timed out with: %s", self._nick, message) return False - def get_messagess(self) -> list[Message]: + def get_messages(self) -> list[Message]: messages: list[Message] = [] data = self._receive_messages() if not data: -- 2.30.2