I am running a get request that is retrieving the status of a specific server process and I want to rerun this request within the script until the status returns finished so that I can execute follow-up functions in my script.
The code I have so far includes a function that does the get request to get the current status and a while loop that is supposed to rerun the function as long as it returns "PENDING" but its not working as intended.
def get_status(id, token):
url = "exampleurl.com/status"
headers = {'Authorization' : 'Bearer ' + token}
response = requests.request("GET", url, headers=headers)
resp_dict = json.loads(response.text)
current_status = resp_dict['status']
return current_status
while status(id, key) == 'PENDING':
status(id, key)
if status(id, key) == 'FINISHED':
print('its done')