From fb4e53c072f667c3bf5ca0625a769e0206477e8a Mon Sep 17 00:00:00 2001 From: Thorsten Date: Fri, 23 Aug 2024 22:52:48 +0200 Subject: [PATCH] fix bug. --- src/distbot/plugins/searx.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 -- 2.39.2