mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 12:10:11 +01:00
Implement "engine_exc_info" to allow removing exception logging in Checker
This commit is contained in:
parent
4f7dd05d99
commit
9f7244d6f1
@ -357,6 +357,7 @@ class Checker: # pylint: disable=missing-class-docstring
|
||||
|
||||
def __init__(self, processor: EngineProcessor):
|
||||
self.processor = processor
|
||||
self.processor.engine_exc_info = False # Remove exception information from errors to reduce verbosity
|
||||
self.tests = self.processor.get_tests()
|
||||
self.test_results = TestResults()
|
||||
|
||||
@ -418,8 +419,10 @@ class Checker: # pylint: disable=missing-class-docstring
|
||||
result_container_check.check_basic()
|
||||
return result_container_check
|
||||
|
||||
def run_test(self, test_name):
|
||||
def run_test(self, test_name: str):
|
||||
test_parameters = self.tests[test_name]
|
||||
# Not really a warning, but an info log will not appear
|
||||
logger.warning('running test: %s', test_name)
|
||||
search_query_list = list(Checker.search_query_matrix_iterator(self.engineref_list, test_parameters['matrix']))
|
||||
rct_list = [self.get_result_container_tests(test_name, search_query) for search_query in search_query_list]
|
||||
stop_test = False
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from logging import Logger
|
||||
import threading
|
||||
from abc import abstractmethod, ABC
|
||||
from timeit import default_timer
|
||||
@ -58,12 +59,13 @@ class SuspendedStatus:
|
||||
class EngineProcessor(ABC):
|
||||
"""Base classes used for all types of request processors."""
|
||||
|
||||
__slots__ = 'engine', 'engine_name', 'lock', 'suspended_status', 'logger'
|
||||
__slots__ = 'engine', 'engine_name', 'lock', 'suspended_status', 'logger', 'engine_exc_info'
|
||||
|
||||
def __init__(self, engine, engine_name: str):
|
||||
self.engine = engine
|
||||
self.engine_name = engine_name
|
||||
self.logger = engines[engine_name].logger
|
||||
self.logger: Logger = engines[engine_name].logger
|
||||
self.engine_exc_info = True
|
||||
key = get_network(self.engine_name)
|
||||
key = id(key) if key else self.engine_name
|
||||
self.suspended_status = SUSPENDED_STATUS.setdefault(key, SuspendedStatus())
|
||||
|
@ -180,20 +180,21 @@ class OnlineProcessor(EngineProcessor):
|
||||
self.logger.exception(
|
||||
"requests exception (search duration : {0} s, timeout: {1} s) : {2}".format(
|
||||
default_timer() - start_time, timeout_limit, e
|
||||
)
|
||||
),
|
||||
exc_info=self.engine_exc_info,
|
||||
)
|
||||
except SearxEngineCaptchaException as e:
|
||||
self.handle_exception(result_container, e, suspend=True)
|
||||
self.logger.exception('CAPTCHA')
|
||||
self.logger.exception('CAPTCHA', exc_info=self.engine_exc_info)
|
||||
except SearxEngineTooManyRequestsException as e:
|
||||
self.handle_exception(result_container, e, suspend=True)
|
||||
self.logger.exception('Too many requests')
|
||||
self.logger.exception('Too many requests', exc_info=self.engine_exc_info)
|
||||
except SearxEngineAccessDeniedException as e:
|
||||
self.handle_exception(result_container, e, suspend=True)
|
||||
self.logger.exception('SearXNG is blocked')
|
||||
self.logger.exception('SearXNG is blocked', exc_info=self.engine_exc_info)
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
self.handle_exception(result_container, e)
|
||||
self.logger.exception('exception : {0}'.format(e))
|
||||
self.logger.exception('exception : {0}'.format(e), exc_info=self.engine_exc_info)
|
||||
|
||||
def get_default_tests(self):
|
||||
tests = {}
|
||||
|
Loading…
Reference in New Issue
Block a user