From 64e54dfc81532c1e748dcebfaf573b76561f3b08 Mon Sep 17 00:00:00 2001 From: maxwgod <30300032+maxwbot@users.noreply.github.com> Date: Wed, 7 Sep 2022 10:30:41 -0300 Subject: [PATCH] Try 9 times before Timeout Error 529 Try 9 times before timeout: Code error 529 'Max retries exceeded'. I added a 1 second increment per attempt too. --- check_azure_resource.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/check_azure_resource.py b/check_azure_resource.py index b17712f..a2f27ac 100755 --- a/check_azure_resource.py +++ b/check_azure_resource.py @@ -36,11 +36,24 @@ def _call_arm_rest_api(client, path, api_version, method='GET', body=None, query request = getattr(client, method.lower())( url=path, params=dict(query or {}, **{'api-version': api_version}) ) - response = client.send( - request=request, content=body, - headers=dict(headers or {}, **{'Content-Type': 'application/json; charset=utf-8'}), - timeout=timeout - ) + + count=0 + timeout=10 + while True: + try: + count+=1 + response = client.send( + request=request, content=body, + headers=dict(headers or {}, **{'Content-Type': 'application/json; charset=utf-8'}), + timeout=timeout + ) + except: + timeout+=1 + if count >= 9: + print(f'Timeout! {timeout:.2f}') + break + else: + break try: response.raise_for_status()