Skip to content

Instantly share code, notes, and snippets.

@chartjes
Created October 24, 2018 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chartjes/67a752d73c5867b18bb3a9a898dbb93d to your computer and use it in GitHub Desktop.
Save chartjes/67a752d73c5867b18bb3a9a898dbb93d to your computer and use it in GitHub Desktop.
How to make this more ideomatically pythonic
while test_completed is False:
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
container_status = i.status.container_statuses
for container in container_status:
if isinstance(container.state.terminated, client.V1ContainerStateTerminated):
if container.state.terminated.reason == 'Completed':
bar.finish()
test_completed = True
if container.state.terminated.exit_code == 0:
print('Loadtest containers exited without errors')
else:
print('Loadtest containers exited with errors, check logs')
bar.update()
@chartjes
Copy link
Author

Hey Tarek,

Thanks for all the suggestions. I do want the while loop to end once the containers have completed running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment