on master help sign in
[fix] checker: fix engine statistics

Without this commit, the URL /stats/errors shows percentage above 100% after the checker has run.

commitd473407ec97107022ccbdd366559001b1ec162d8 authorAlexandre Flament <alex@al-f.net> dateSun 17 Jan 2021, 16:14 (6 years ago) parentca76f31
3 files changed+7−4
searx/metrology/error_recorder.py+2−2 searx/search/checker/impl.py+3 searx/search/processors/abstract.py+2−2
searx/metrology/error_recorder.py+2−2
@@ -53,9 +53,9 @@ def add_error_context(engine_name: str, error_context: ErrorContext) -> None:
5353def get_trace(traces):
5454 for trace in reversed(traces):
5555 split_filename = trace.filename.split('/')
56− if len(split_filename) > 3 and '/'.join(split_filename[-3:-1]) == 'searx/engines':
56+ if '/'.join(split_filename[-3:-1]) == 'searx/engines':
5757 return trace
58− if len(split_filename) > 3 and '/'.join(split_filename[-4:-1]) == 'searx/search/processors':
58+ if '/'.join(split_filename[-4:-1]) == 'searx/search/processors':
5959 return trace
6060 return traces[-1]
6161
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