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