From 7571b4519e54e2e747a21f7f900e486ccee19aa0 Mon Sep 17 00:00:00 2001 From: Prabha <58968096+steveprabha@users.noreply.github.com> Date: Sun, 2 May 2021 21:38:37 +0530 Subject: [PATCH] Update job_crud.py --- examples/job_crud.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/job_crud.py b/examples/job_crud.py index e25f330d6..ea454aea9 100644 --- a/examples/job_crud.py +++ b/examples/job_crud.py @@ -55,15 +55,17 @@ def create_job(api_instance, job): api_response = api_instance.create_namespaced_job( body=job, namespace="default") - # Need to wait for a second for the job status to update - sleep(1) print("Job created. status='%s'" % str(get_job_status(api_instance))) def get_job_status(api_instance): - api_response = api_instance.read_namespaced_job_status( - name=JOB_NAME, - namespace="default") + job_completed = False + while not job_completed: + api_response = api_instance.read_namespaced_job_status( + name=JOB_NAME, + namespace="default") + if api_response.status.succeeded is not None or api_response.status.failed is not None: + job_completed = True return api_response.status