error handling for delete

This commit is contained in:
Simon 2018-11-18 11:19:34 -05:00
parent 254d6ea44e
commit 750940d148

View File

@ -114,6 +114,7 @@ class ElasticSearchEngine(SearchEngine):
def delete_docs(self, website_id): def delete_docs(self, website_id):
while True:
try: try:
logger.debug("Deleting docs of " + str(website_id)) logger.debug("Deleting docs of " + str(website_id))
@ -121,7 +122,7 @@ class ElasticSearchEngine(SearchEngine):
"query": { "query": {
"term": {"website_id": website_id} "term": {"website_id": website_id}
} }
}, scroll="1m", client=self.es, index=self.index_name, request_timeout=60) }, scroll="1m", client=self.es, index=self.index_name, request_timeout=120)
buf = [] buf = []
counter = 0 counter = 0
@ -135,9 +136,11 @@ class ElasticSearchEngine(SearchEngine):
counter = 0 counter = 0
if counter > 0: if counter > 0:
self._delete(buf) self._delete(buf)
break
except Exception as e: except Exception as e:
logger.error(str(e)) logger.error("During delete: " + str(e))
time.sleep(10)
logger.debug("Done deleting for " + str(website_id)) logger.debug("Done deleting for " + str(website_id))