0

I have to write a script to catch some info in an API with python It looks like this post Tell when Job is Complete but without Kubernetes stuff

I have a json format like this :

[{'name': 'E56a, character.',
'results': '*some url link*',
'status': 'Complete',
'token': 'qFTDHYiuf514oz'}]

When I submit my job, the status is 'running' until it finished and became 'complete' but It last about one hour and depend on the file I want to submit to the website ... I wanted to know how can write in my script something that will allow me to download result when the status key is completed?

Thanks

1 Answers1

1

You can write an infinite loop that checks every 60 seconds (you can change the interval) if the job is ready:

import time
while True:
    if job["status"] == "Completed":
        download_results() # implement here your logic
        break
    else:
        print("Job is not ready, waiting...")
        time.sleep(60) # you can change the check interval

Gabio
  • 9,126
  • 3
  • 12
  • 32