mirror of
https://github.com/searxng/searxng.git
synced 2026-07-30 11:51:24 +00:00
[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:
@@ -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
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user