[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>
This commit is contained in:
Markus Heiser 2025-11-23 11:19:45 +01:00 committed by Markus Heiser
parent 5fcee9bc30
commit 3f30831640

View File

@ -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())