From 339738275446dc185e761bdc3f4714cf29d33fd8 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 7 Sep 2020 15:39:26 +0200 Subject: [PATCH] [enh] stop searx when an engine raise an SyntaxError exception (#2177) and some other exceptions: * KeyboardInterrupt * SystemExit * RuntimeError * SystemError * ImportError: an engine with an unmet dependency will stop everything. --- searx/engines/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 48c02e2e7..9fcf812b0 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -74,6 +74,9 @@ def load_engine(engine_data): try: engine = load_module(engine_module + '.py', engine_dir) + except (SyntaxError, KeyboardInterrupt, SystemExit, SystemError, ImportError, RuntimeError) as e: + logger.exception('Fatal exception in engine "{}"'.format(engine_module)) + sys.exit(1) except: logger.exception('Cannot load engine "{}"'.format(engine_module)) return None