on master help sign in
Merge pull request #2476 from dalf/fix-error-recording-and-checker

Fix error recording and checker

commit0495e15df4b5e88adef24a9b5c3dbb35e4fac072 authorAlexandre Flament <alex@al-f.net> dateMon 18 Jan 2021, 08:29 (6 years ago) parent80d741167a1aab
4 files changed+11−11
searx/metrology/error_recorder.py+5−8 searx/search/checker/background.py+1−1 searx/search/checker/impl.py+3 searx/search/processors/abstract.py+2−2
searx/metrology/error_recorder.py+5−8
@@ -51,15 +51,12 @@ def add_error_context(engine_name: str, error_context: ErrorContext) -> None:
5151
5252
5353def get_trace(traces):
54− previous_trace = traces[-1]
5554 for trace in reversed(traces):
56− if trace.filename.endswith('searx/search.py'):
57− if previous_trace.filename.endswith('searx/poolrequests.py'):
58− return trace
59− if previous_trace.filename.endswith('requests/models.py'):
60− return trace
61− return previous_trace
62− previous_trace = trace
55+ split_filename = trace.filename.split('/')
56+ if '/'.join(split_filename[-3:-1]) == 'searx/engines':
57+ return trace
58+ if '/'.join(split_filename[-4:-1]) == 'searx/search/processors':
59+ return trace
6360 return traces[-1]
6461
6562
searx/search/checker/background.py+1−1
@@ -98,7 +98,7 @@ def initialize():
9898 signal.signal(signal.SIGUSR1, _signal_handler)
9999
100100 # disabled by default
101− _set_result({'status': 'disabled'})
101+ _set_result({'status': 'disabled'}, include_timestamp=False)
102102
103103 # special case when debug is activate
104104 if searx_debug and settings.get('checker', {}).get('off_when_debug', True):
searx/search/checker/impl.py+3
@@ -4,6 +4,7 @@ import typing
44import types
55import functools
66import itertools
7+import threading
78from time import time
89from urllib.parse import urlparse
910
@@ -377,6 +378,8 @@ class Checker:
377378 engineref_category = search_query.engineref_list[0].category
378379 params = self.processor.get_params(search_query, engineref_category)
379380 if params is not None:
381+ with threading.RLock():
382+ self.processor.engine.stats['sent_search_count'] += 1
380383 self.processor.search(search_query.query, params, result_container, time(), 5)
381384 return result_container
382385
searx/search/processors/abstract.py+2−2
@@ -1,13 +1,13 @@
11# SPDX-License-Identifier: AGPL-3.0-or-later
22
3−from abc import abstractmethod
3+from abc import abstractmethod, ABC
44from searx import logger
55
66
77logger = logger.getChild('searx.search.processor')
88
99
10−class EngineProcessor:
10+class EngineProcessor(ABC):
1111
1212 def __init__(self, engine, engine_name):
1313 self.engine = engine