[fix] clarify the mess of Engine.setup and Engine.init (#6343)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser
2026-06-30 19:22:23 +02:00
committed by GitHub
parent c5b1d066e5
commit d115c61a70
4 changed files with 52 additions and 28 deletions

View File

@@ -16,6 +16,7 @@ __all__ = [
import typing as t
import os
from searx import logger
from searx import engines
@@ -92,7 +93,9 @@ class ProcessorMap(dict[str, EngineProcessor]):
self[eng_proc.engine.name] = eng_proc
# logger.debug("registered engine processor: %s", eng_proc.engine.name)
else:
logger.error("can't register engine processor: %s (init failed)", eng_proc.engine.name)
logger.error(
f"(PID {os.getpid()}) {eng_proc.engine.name}: can't register engines processor (init engine failed)"
)
return eng_proc_ok

View File

@@ -150,19 +150,26 @@ class EngineProcessor(ABC):
threading.Thread(target=__init_processor_thread, daemon=True).start()
def init_engine(self) -> bool:
eng_setting = get_engine_from_settings(self.engine.name)
init_ok: bool | None = False
try:
init_ok = self.engine.init(eng_setting)
except Exception: # pylint: disable=broad-except
logger.exception(
f"(PID {os.getpid()}) Init method of engine %s failed due to an exception.", self.engine.name
)
except Exception as e: # pylint: disable=broad-except
logger.exception(f"(PID {os.getpid()}) {self.engine.name}: engine INIT failed, exception: {e}")
init_ok = False
# In older engines, None is returned from the init method, which is
# equivalent to indicating that the initialization was successful.
# equivalent to indicating that the initialization was successful
# (compare: Engine.setup).
if init_ok is None:
init_ok = True
if not init_ok:
logger.error(f"(PID {os.getpid()}) {self.engine.name}: engine init was not successful")
return init_ok
def handle_exception(