]> git.aero2k.de Git - urlbot-v3.git/commitdiff
fix bug.
authorThorsten <mail@aero2k.de>
Fri, 23 Aug 2024 20:52:48 +0000 (22:52 +0200)
committerThorsten <mail@aero2k.de>
Fri, 23 Aug 2024 20:52:48 +0000 (22:52 +0200)
src/distbot/plugins/searx.py

index 228fe8adf84f4f4dbfb58d546207eaa20a0de3e5..30258f42bcc0130183feedba8fcced5f2cf9d3b5 100644 (file)
@@ -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