mirror of
https://github.com/searxng/searxng.git
synced 2025-11-30 02:05:28 -05:00
[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:
parent
5fcee9bc30
commit
3f30831640
@ -22,7 +22,7 @@ from searx.network import initialize as initialize_network, check_network_config
|
|||||||
from searx.results import ResultContainer
|
from searx.results import ResultContainer
|
||||||
from searx.search.checker import initialize as initialize_checker
|
from searx.search.checker import initialize as initialize_checker
|
||||||
from searx.search.processors import PROCESSORS
|
from searx.search.processors import PROCESSORS
|
||||||
|
from searx.search.processors.abstract import RequestParams
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
from .models import SearchQuery
|
from .models import SearchQuery
|
||||||
@ -79,16 +79,20 @@ class Search:
|
|||||||
return bool(results)
|
return bool(results)
|
||||||
|
|
||||||
# do search-request
|
# 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
|
# init vars
|
||||||
requests: list[tuple[str, str, dict[str, t.Any]]] = []
|
requests: list[tuple[str, str, RequestParams]] = []
|
||||||
|
|
||||||
# max of all selected engine timeout
|
# max of all selected engine timeout
|
||||||
default_timeout = 0
|
default_timeout = 0
|
||||||
|
|
||||||
# start search-request for all selected engines
|
# start search-request for all selected engines
|
||||||
for engineref in self.search_query.engineref_list:
|
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
|
# stop the request now if the engine is suspend
|
||||||
if processor.extend_container_if_suspended(self.result_container):
|
if processor.extend_container_if_suspended(self.result_container):
|
||||||
@ -133,7 +137,7 @@ class Search:
|
|||||||
|
|
||||||
return requests, actual_timeout
|
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
|
# pylint: disable=protected-access
|
||||||
search_id = str(uuid4())
|
search_id = str(uuid4())
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user