From: Thorsten Date: Fri, 23 Aug 2024 20:52:48 +0000 (+0200) Subject: fix bug. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=fb4e53c072f667c3bf5ca0625a769e0206477e8a;p=urlbot-v3.git fix bug. --- diff --git a/src/distbot/plugins/searx.py b/src/distbot/plugins/searx.py index 228fe8a..30258f4 100644 --- a/src/distbot/plugins/searx.py +++ b/src/distbot/plugins/searx.py @@ -56,8 +56,8 @@ class Searx(Worker): return searxes @retry(ExceptionToCheck=(ConnectionError, BrokenSearxError, RateLimitingError, json.JSONDecodeError, SSLError), - tries=10, delay=1, backoff=1.1, logger=logger) - def searx(self, text): + tries=10, delay=1, backoff=2, logger=logger) + def searx(self, text, retries=0): if not self.search_list: self.search_list = self.fetch_all_searx_engines() @@ -90,10 +90,15 @@ class Searx(Worker): raise if not response.get('results', []): - if response.get("unresponsive_engines", []): - logger.debug("drop search engine, probably has issues: %s", self.search_list[0]) + unresponsive_engines = response.get("unresponsive_engines", []) + if unresponsive_engines: + logger.warning("drop search engine, probably has issues: %s (engine issues: %s)", self.search_list[0], unresponsive_engines) self.search_list.pop(0) - return self.searx(text) + if retries < 3: + return self.searx(text, retries+1) + else: + logger.warning("Retries exceeded while iterating searx instances for a result") + return logger.info("No results found, response: %s", response) return