diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2025-11-23 11:19:45 +0100 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-11-25 06:25:45 +0100 |
| commit | 3f3083164096ecb1ec57cf84d6242c296d450a78 (patch) | |
| tree | f47efca69d884631b4754472e3c10d9924edecb3 /searx/search | |
| parent | 5fcee9bc307f6d3592ebcb1db4f4f8834df6f495 (diff) | |
[fix] don't raise fatal exception when engine isn't available
When wikidata or any other engine with a init method (is active!) raises an
exception in it's init method, the engine is never registered.
[1] https://github.com/searxng/searxng/issues/5456#issuecomment-3567790287
Closes: https://github.com/searxng/searxng/issues/5456
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/search')
| -rw-r--r-- | searx/search/__init__.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/searx/search/__init__.py b/searx/search/__init__.py index 62539579c..e4282512b 100644 --- a/searx/search/__init__.py +++ b/searx/search/__init__.py @@ -22,7 +22,7 @@ from searx.network import initialize as initialize_network, check_network_config from searx.results import ResultContainer from searx.search.checker import initialize as initialize_checker from searx.search.processors import PROCESSORS - +from searx.search.processors.abstract import RequestParams if t.TYPE_CHECKING: from .models import SearchQuery @@ -79,16 +79,20 @@ class Search: return bool(results) # do search-request - def _get_requests(self) -> tuple[list[tuple[str, str, dict[str, t.Any]]], int]: + def _get_requests(self) -> tuple[list[tuple[str, str, RequestParams]], float]: # init vars - requests: list[tuple[str, str, dict[str, t.Any]]] = [] + requests: list[tuple[str, str, RequestParams]] = [] # max of all selected engine timeout default_timeout = 0 # start search-request for all selected engines for engineref in self.search_query.engineref_list: - processor = PROCESSORS[engineref.name] + processor = PROCESSORS.get(engineref.name) + if not processor: + # engine does not exists; not yet or the 'init' method of the + # engine has been failed and the engine has not been registered. + continue # stop the request now if the engine is suspend if processor.extend_container_if_suspended(self.result_container): @@ -133,7 +137,7 @@ class Search: return requests, actual_timeout - def search_multiple_requests(self, requests: list[tuple[str, str, dict[str, t.Any]]]): + def search_multiple_requests(self, requests: list[tuple[str, str, RequestParams]]): # pylint: disable=protected-access search_id = str(uuid4()) |