8000 Merge pull request #1418 from steveprabha/patch-5 · palnabarun/python@a126ab0 · GitHub
[go: up one dir, main page]

Skip to content

Commit a126ab0

Browse files
authored
Merge pull request kubernetes-client#1418 from steveprabha/patch-5
Make job_crud example print the correct job status after job creation
2 parents 476ce50 + 30477c7 commit a126ab0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/job_crud.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818

1919
from os import path
20+
from time import sleep
2021

2122
import yaml
2223

@@ -54,6 +55,20 @@ def create_job(api_instance, job):
5455
body=job,
5556
namespace="default")
5657
print("Job created. status='%s'" % str(api_response.status))
58+
get_job_status(api_instance)
59+
60+
61+
def get_job_status(api_instance):
62+
job_completed = False
63+
while not job_completed:
64+
api_response = api_instance.read_namespaced_job_status(
65+
name=JOB_NAME,
66+
namespace="default")
67+
if api_response.status.succeeded is not None or \
68+
api_response.status.failed is not None:
69+
job_completed = True
70+
sleep(1)
71+
print("Job status='%s'" % str(api_response.status))
5772

5873

5974
def update_job(api_instance, job):

0 commit comments

Comments
 (0)
0