mirror of https://github.com/searxng/searxng.git
Merge pull request #2476 from dalf/fix-error-recording-and-checker
Fix error recording and checker
This commit is contained in:
commit
0495e15df4
|
@ -51,15 +51,12 @@ def add_error_context(engine_name: str, error_context: ErrorContext) -> None:
|
||||||
|
|
||||||
|
|
||||||
def get_trace(traces):
|
def get_trace(traces):
|
||||||
previous_trace = traces[-1]
|
|
||||||
for trace in reversed(traces):
|
for trace in reversed(traces):
|
||||||
if trace.filename.endswith('searx/search.py'):
|
split_filename = trace.filename.split('/')
|
||||||
if previous_trace.filename.endswith('searx/poolrequests.py'):
|
if '/'.join(split_filename[-3:-1]) == 'searx/engines':
|
||||||
return trace
|
return trace
|
||||||
if previous_trace.filename.endswith('requests/models.py'):
|
if '/'.join(split_filename[-4:-1]) == 'searx/search/processors':
|
||||||
return trace
|
return trace
|
||||||
return previous_trace
|
|
||||||
previous_trace = trace
|
|
||||||
return traces[-1]
|
return traces[-1]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ def initialize():
|
||||||
signal.signal(signal.SIGUSR1, _signal_handler)
|
signal.signal(signal.SIGUSR1, _signal_handler)
|
||||||
|
|
||||||
# disabled by default
|
# disabled by default
|
||||||
_set_result({'status': 'disabled'})
|
_set_result({'status': 'disabled'}, include_timestamp=False)
|
||||||
|
|
||||||
# special case when debug is activate
|
# special case when debug is activate
|
||||||
if searx_debug and settings.get('checker', {}).get('off_when_debug', True):
|
if searx_debug and settings.get('checker', {}).get('off_when_debug', True):
|
||||||
|
|
|
@ -4,6 +4,7 @@ import typing
|
||||||
import types
|
import types
|
||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
|
import threading
|
||||||
from time import time
|
from time import time
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
@ -377,6 +378,8 @@ class Checker:
|
||||||
engineref_category = search_query.engineref_list[0].category
|
engineref_category = search_query.engineref_list[0].category
|
||||||
params = self.processor.get_params(search_query, engineref_category)
|
params = self.processor.get_params(search_query, engineref_category)
|
||||||
if params is not None:
|
if params is not None:
|
||||||
|
with threading.RLock():
|
||||||
|
self.processor.engine.stats['sent_search_count'] += 1
|
||||||
self.processor.search(search_query.query, params, result_container, time(), 5)
|
self.processor.search(search_query.query, params, result_container, time(), 5)
|
||||||
return result_container
|
return result_container
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod, ABC
|
||||||
from searx import logger
|
from searx import logger
|
||||||
|
|
||||||
|
|
||||||
logger = logger.getChild('searx.search.processor')
|
logger = logger.getChild('searx.search.processor')
|
||||||
|
|
||||||
|
|
||||||
class EngineProcessor:
|
class EngineProcessor(ABC):
|
||||||
|
|
||||||
def __init__(self, engine, engine_name):
|
def __init__(self, engine, engine_name):
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
|
|
Loading…
Reference in New Issue