offline.py 971 B

123456789101112131415161718192021222324252627
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. """Processors for engine-type: ``offline``
  3. """
  4. from .abstract import EngineProcessor
  5. class OfflineProcessor(EngineProcessor):
  6. """Processor class used by ``offline`` engines"""
  7. engine_type = 'offline'
  8. def _search_basic(self, query, params):
  9. return self.engine.search(query, params)
  10. def search(self, query, params, result_container, start_time, timeout_limit):
  11. try:
  12. search_results = self._search_basic(query, params)
  13. self.extend_container(result_container, start_time, search_results)
  14. except ValueError as e:
  15. # do not record the error
  16. self.logger.exception('engine {0} : invalid input : {1}'.format(self.engine_name, e))
  17. except Exception as e: # pylint: disable=broad-except
  18. self.handle_exception(result_container, e)
  19. self.logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e))