I need to calling API till the status of a job in the response will be changed from "WAITING" to "DONE" (the job changes the status from 1 minute to 1 hour).
async def wait_until_job_status_done(url_api):
async with self._session.get(url) as resp:
await asyncio.sleep(1)
resp.raise_for_status()
job_status_data = await resp.json()
job_status = job_status_data["status"]
if job_status_data["status"] == "WAITING":
await wait_until_job_status_done(url_api)
This gives rise to the following error:
RecursionError: maximum recursion depth exceeded
The question: How can I change the function from recursive to non-recursive ? Thank you