From: Georgios Atheridis Date: Tue, 5 Sep 2023 23:47:23 +0000 (+0100) Subject: Fix TimeoutError Bug X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;ds=sidebyside;p=personal%2Faptbot.git Fix TimeoutError Bug Handle all OSError exceptions rather than just ConnectionError. Allowing the to reset itself rather than fail in certain cases. --- 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: