Skip to content

Commit

Permalink
Add max iterations for waiting on job to enter ready state in the dat…
Browse files Browse the repository at this point in the history
…abase
  • Loading branch information
meganerd committed Feb 6, 2024
1 parent 00eb275 commit 7470ec8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nautobot_chatops/workers/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,12 @@ def init_job(dispatcher, *args, job_name: str = "", json_string_kwargs: str = ""
)

# Wait on the job to finish
max_wait_iterations = 60
while job_result.status not in JobResultStatusChoices.READY_STATES:
max_wait_iterations -= 1
if not max_wait_iterations:
dispatcher.send_error(f"The requested job {job_name} failed to reach ready state.")
return (CommandStatusChoices.STATUS_FAILED, f'Job "{job_name}" failed to reach ready state.')
time.sleep(1)
job_result.refresh_from_db()

Expand Down

0 comments on commit 7470ec8

Please sign in to comment.