@@ -95,12 +95,14 @@ def f_retry(*args, **kwargs):
9595 # ADAL error corresponds to everything but 429, which bubbles up HTTP error.
9696 last_exception = e
9797 logger .exception ("Retry count " + str (retry_count ) + "Exception :" + str (last_exception ))
98-
99- if hasattr (last_exception , 'error_response' ): # ADAL exception
100- response = response_from_adal_exception (last_exception )
101- if hasattr (last_exception , 'response' ): # HTTP exception i.e 429
102- response = last_exception .response
103-
98+ # We don't want to stop retry for any error in parsing the exception. This is a GET operation.
99+ try :
100+ if hasattr (last_exception , 'error_response' ): # ADAL exception
101+ response = response_from_adal_exception (last_exception )
102+ if hasattr (last_exception , 'response' ): # HTTP exception i.e 429
103+ response = last_exception .response
104+ except :
105+ pass
104106 request_successful = last_exception is None or (response is not None and response .status_code == 401 ) # 401 = Invalid credentials
105107 if request_successful or not retry_policy .should_retry (response , last_exception , retry_count ):
106108 break
@@ -116,15 +118,11 @@ def response_from_adal_exception(e):
116118 import re
117119 from collections import namedtuple
118120
119- response = e .error_response
120- http_code = re .search ("http error: (\d+)" , str (e ))
121+ http_code = re .search (r"http error: (\d+)" , str (e ))
121122 if http_code is not None : # Add status_code to response object for use in should_retry
122- keys = list (response .keys ()) + ['status_code' ]
123- status_code = int (http_code .group (1 ))
124- values = list (response .values ()) + [status_code ]
125-
126- Response = namedtuple ("Response" , keys )
123+ status_code = [int (http_code .group (1 ))]
124+ Response = namedtuple ("Response" , ['status_code' ])
127125 response = Response (
128- * values ) # Construct response object with adal exception response and http code
126+ * status_code ) # Construct response object with adal exception response and http code
129127 return response
130128
0 commit comments