ca†ch 503 before parsing json

This commit is contained in:
VJHack 2024-09-12 20:44:45 -05:00
parent 161bf2205d
commit 8b7daaaef2

View file

@ -1208,14 +1208,12 @@ async def wait_for_slots_status(context,
while True:
async with await session.get(f'{base_url}/slots', params=params) as slots_response:
status_code = slots_response.status
try:
slots = await slots_response.json()
except:
slots = await slots_response.text()
if context.debug:
print(f"slots responses {slots}\n")
if status_code == 503 and status_code == expected_http_status_code:
return
slots = await slots_response.json()
if context.debug:
print(f"slots responses {slots}\n")
if status_code == 200 and status_code == expected_http_status_code:
n_slots_idle = sum(1 if slot["state"] == 0 else 0 for slot in slots)
n_slots_processing = sum(1 if slot["state"] != 0 else 0 for slot in slots)