Python 请求:状态完成时下载

Python request : download when status complete

我必须编写一个脚本来使用 python 在 API 中捕获一些信息 看起来像这样 post 但没有 Kubernetes 的东西

我有这样的 json 格式:

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

当我提交我的工作时,状态是 'running' 直到它完成并变成 'complete' 但它持续大约一个小时,取决于我要提交到网站的文件...... 我想知道如何在我的脚本中写一些东西,让我在状态键完成时下载结果?

谢谢

您可以编写一个无限循环,每 60 秒检查一次(您可以更改间隔)作业是否就绪:

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