2020-12-16 13:41:32 +01:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2021-04-27 15:13:39 +02:00
|
|
|
# lint: pylint
|
2020-12-16 13:41:32 +01:00
|
|
|
|
2021-04-27 15:13:39 +02:00
|
|
|
"""Processores for engine-type: ``offline``
|
2020-12-16 13:41:32 +01:00
|
|
|
|
2021-04-27 15:13:39 +02:00
|
|
|
"""
|
2020-12-16 13:41:32 +01:00
|
|
|
|
2021-04-27 15:13:39 +02:00
|
|
|
from .abstract import EngineProcessor
|
2020-12-16 13:41:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
class OfflineProcessor(EngineProcessor):
|
2021-04-27 15:13:39 +02:00
|
|
|
"""Processor class used by ``offline`` engines"""
|
2020-12-16 13:41:32 +01:00
|
|
|
|
|
|
|
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)
|
2021-04-13 15:21:53 +02:00
|
|
|
self.extend_container(result_container, start_time, search_results)
|
2020-12-16 13:41:32 +01:00
|
|
|
except ValueError as e:
|
2021-04-13 15:21:53 +02:00
|
|
|
# do not record the error
|
2021-09-06 19:46:08 +02:00
|
|
|
self.logger.exception('engine {0} : invalid input : {1}'.format(self.engine_name, e))
|
2021-12-27 09:26:22 +01:00
|
|
|
except Exception as e: # pylint: disable=broad-except
|
2021-04-26 11:12:02 +02:00
|
|
|
self.handle_exception(result_container, e)
|
2021-09-06 19:46:08 +02:00
|
|
|
self.logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e))
|