Fix TimeoutError Bug main
authorGeorgios Atheridis <georgios@atheridis.org>
Tue, 5 Sep 2023 23:47:23 +0000 (00:47 +0100)
committerGeorgios Atheridis <georgios@atheridis.org>
Tue, 5 Sep 2023 23:47:23 +0000 (00:47 +0100)
Handle all OSError exceptions rather than just ConnectionError. Allowing
the to reset itself rather than fail in certain cases.

aptbot/bot.py

index 1ef4b474960a3b874f6058a9bd92adf220bbdded..eccf10872d22f6c52fdc50ef92cfaa3183dd13b8 100644 (file)
@@ -216,7 +216,7 @@ class Bot(ABCBot):
     def _receive_messages(self) -> bytes:
         try:
             data = self._irc.recv(self._BYTE_READ)
     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""
             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)
             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(
                 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
 
         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:
         messages: list[Message] = []
         data = self._receive_messages()
         if not data: