Skip to content

Commit

Permalink
Merge pull request #1725 from BLSQ/IA-3572_setuper-error-no-worker
Browse files Browse the repository at this point in the history
[IA-3572] Setuper error after worker timeout
  • Loading branch information
tdethier authored Oct 21, 2024
2 parents 7d57574 + 9da5929 commit 3a3e6cd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions setuper/iaso_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@


class IasoClient:
ASYNC_TASK_TIMEOUT = 120
ASYNC_TASK_WAIT_STEP = 5

def __init__(self, server_url):
self.debug = False
self.server_url = server_url
Expand Down Expand Up @@ -74,15 +77,18 @@ def wait_task_completion(self, task_to_wait):
print(f"\tWaiting for async task '{task_to_wait['task']['name']}'")
count = 0
imported = False
while not imported and count < 120:
while not imported and count < self.ASYNC_TASK_TIMEOUT:
task = self.get(f"/api/tasks/{task_to_wait['task']['id']}")
imported = task["status"] == "SUCCESS"

if task["status"] == "ERRORED":
raise Exception(f"Task failed {task}")
time.sleep(2)
count += 5
time.sleep(self.ASYNC_TASK_WAIT_STEP)
count += self.ASYNC_TASK_WAIT_STEP
print("\t\tWaiting:", count, "s elapsed", task.get("progress_message"))
raise Exception(
f"Couldn't find an available worker after {self.ASYNC_TASK_TIMEOUT} seconds. Please make sure a worker is running."
)

def log(self, arg1, arg2=None):
if self.debug:
Expand Down

0 comments on commit 3a3e6cd

Please sign in to comment.