mirror of
https://github.com/searxng/searxng.git
synced 2024-08-24 23:13:33 +02:00
Report to the user suspended engines. searx.search.processor.abstract: * manages suspend time (per network). * reports suspended time to the ResultContainer (method extend_container_if_suspended) * adds the results to the ResultContainer (method extend_container) * handles exceptions (method handle_exception)
27 lines
956 B
Python
27 lines
956 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
from searx import logger
|
|
from searx.search.processors.abstract import EngineProcessor
|
|
|
|
|
|
logger = logger.getChild('searx.search.processor.offline')
|
|
|
|
|
|
class OfflineProcessor(EngineProcessor):
|
|
|
|
engine_type = 'offline'
|
|
|
|
def _search_basic(self, query, params):
|
|
return self.engine.search(query, params)
|
|
|
|
def search(self, query, params, result_container, start_time, timeout_limit):
|
|
try:
|
|
search_results = self._search_basic(query, params)
|
|
self.extend_container(result_container, start_time, search_results)
|
|
except ValueError as e:
|
|
# do not record the error
|
|
logger.exception('engine {0} : invalid input : {1}'.format(self.engine_name, e))
|
|
except Exception as e:
|
|
self.handle_exception(result_container, 'unexpected crash', e)
|
|
logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e))
|