mirror of
https://github.com/simon987/od-database.git
synced 2025-04-17 17:36:48 +00:00
retry on index fail/timeout
This commit is contained in:
parent
5782a45524
commit
a33d4f2dca
@ -179,13 +179,15 @@ class ElasticSearchEngine(SearchEngine):
|
||||
self._index(docs)
|
||||
|
||||
def _index(self, docs):
|
||||
while True:
|
||||
try:
|
||||
logger.debug("Indexing " + str(len(docs)) + " docs")
|
||||
bulk_string = ElasticSearchEngine.create_bulk_index_string(docs)
|
||||
result = self.es.bulk(body=bulk_string, index=self.index_name, doc_type="file", request_timeout=30)
|
||||
|
||||
if result["errors"]:
|
||||
logger.error("Error in ES bulk index: \n" + result["errors"])
|
||||
raise IndexingError
|
||||
self.es.bulk(body=bulk_string, index=self.index_name, doc_type="file", request_timeout=30)
|
||||
break
|
||||
except Exception as e:
|
||||
logger.error("Error in _index: " + str(e) + ", retrying")
|
||||
time.sleep(10)
|
||||
|
||||
@staticmethod
|
||||
def create_bulk_index_string(docs: list):
|
||||
|
Loading…
x
Reference in New Issue
Block a user