Skip to content

Commit

Permalink
when task info is missing assume it's done
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Mar 20, 2024
1 parent cc925b4 commit 175eff2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions eve_elastic/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,11 @@ def _background_reindex(
# first get total number of items
while True:
time.sleep(1.0)
task = es.tasks.get(task_id=task_id)
try:
task = es.tasks.get(task_id=task_id)
except elasticsearch.exceptions.NotFoundError:
print("Task not found, reindexing done.")
return
if task["completed"]:
print_task_done(task)
return
Expand All @@ -1206,7 +1210,11 @@ def _background_reindex(
with progressbar(length=task["task"]["status"]["total"], label="Reindexing") as bar:
while True:
time.sleep(2.0)
task = es.tasks.get(task_id=task_id)
try:
task = es.tasks.get(task_id=task_id)
except elasticsearch.exceptions.NotFoundError:
print("Task not found, reindexing done.")
return
if (
task["task"]["status"]["created"]
and task["task"]["status"]["created"] > last_created
Expand Down

0 comments on commit 175eff2

Please sign in to comment.