From: Christian Heller Date: Mon, 3 Nov 2025 05:02:32 +0000 (+0100) Subject: For interpreting ERROR messages towards connection retries, use regex matching, add... X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/template?a=commitdiff_plain;h=df008e65aae8e54e186b7a12769cb5b4403e0a1e;p=ircplom For interpreting ERROR messages towards connection retries, use regex matching, add "Ping timeout". --- diff --git a/src/ircplom/client.py b/src/ircplom/client.py index 6794583..d9ce45c 100644 --- a/src/ircplom/client.py +++ b/src/ircplom/client.py @@ -4,6 +4,7 @@ from abc import ABC, abstractmethod from base64 import b64encode from dataclasses import dataclass, InitVar from getpass import getuser +from re import search as re_search, IGNORECASE as re_IGNORECASE from threading import Thread from time import sleep from typing import (Any, Callable, Collection, Generic, Iterable, Iterator, @@ -19,6 +20,10 @@ from ircplom.msg_parse_expectations import MSG_EXPECTATIONS _NAMES_DESIRED_SERVER_CAPS = ('sasl',) +_DISCONNECT_MSG_REGEXES_TO_RETRY_ON = ( + r'^Closing Link: \(Connection timed out\)$', + r'^Closing Link: \(Ping timeout: [0-9]+ seconds\)$' +) class SendFail(Exception): @@ -891,9 +896,12 @@ class Client(ABC, ClientQueueMixin): def consider_retry(self) -> None: 'Interpret .db.connection_state, on triggers set retry connect.' - if self.db.connection_state.endswith('timed out)')\ - and not self._retry_connect_in_s > 0: - self._retry_connect_in_s = 1 + if not self._retry_connect_in_s > 0: + for _ in [ + re for re in _DISCONNECT_MSG_REGEXES_TO_RETRY_ON + if re_search(re, self.db.connection_state, re_IGNORECASE)]: + self._retry_connect_in_s = 1 + break def close(self) -> None: 'Close connection, wipe memory of its states, reconnect if indicated.'