diff options
author | Martin Fischer <martin@push-f.com> | 2022-01-17 11:11:39 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2022-01-17 11:42:48 +0100 |
commit | 193b0efd12a78172fec1fef03bfc2f7929c705a3 (patch) | |
tree | 79013143c385efd7946fa531e795c1cc03b554e9 /searx/results.py | |
parent | 0c6a09cae34997b2b5aba83bac50fabacafde59f (diff) | |
download | searxng-193b0efd12a78172fec1fef03bfc2f7929c705a3.tar.gz searxng-193b0efd12a78172fec1fef03bfc2f7929c705a3.zip |
[typing] add results.UnresponsiveEngine
Diffstat (limited to 'searx/results.py')
-rw-r--r-- | searx/results.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/searx/results.py b/searx/results.py index 5e1b46ed5..1ac6a5ab5 100644 --- a/searx/results.py +++ b/searx/results.py @@ -2,7 +2,7 @@ import re from collections import defaultdict from operator import itemgetter from threading import RLock -from typing import List, NamedTuple +from typing import List, NamedTuple, Set from urllib.parse import urlparse, unquote from searx import logger @@ -145,6 +145,12 @@ class Timing(NamedTuple): load: float +class UnresponsiveEngine(NamedTuple): + engine: str + error_type: str + suspended: bool + + class ResultContainer: """docstring for ResultContainer""" @@ -176,7 +182,7 @@ class ResultContainer: self.engine_data = defaultdict(dict) self._closed = False self.paging = False - self.unresponsive_engines = set() + self.unresponsive_engines: Set[UnresponsiveEngine] = set() self.timings: List[Timing] = [] self.redirect_url = None self.on_result = lambda _: True @@ -409,9 +415,9 @@ class ResultContainer: return 0 return resultnum_sum / len(self._number_of_results) - def add_unresponsive_engine(self, engine_name, error_type, suspended=False): + def add_unresponsive_engine(self, engine_name: str, error_type: str, suspended: bool = False): if engines[engine_name].display_error_messages: - self.unresponsive_engines.add((engine_name, error_type, suspended)) + self.unresponsive_engines.add(UnresponsiveEngine(engine_name, error_type, suspended)) def add_timing(self, engine_name: str, engine_time: float, page_load_time: float): self.timings.append(Timing(engine_name, total=engine_time, load=page_load_time)) |