[TestRail] Wait up to 10 min for API is up
Since time to time TestRail goes down (service unavailable error is recieved on all requests), added 503 code to known errors and 10 retries w/ 60 seconds sleep for such cases. Default sleep value was increased from 5 to 60 seconds, because 429 error is always returned w/ 'retry-after' header, so it will be used for handling 503 error only. Change-Id: I87cf4b422d992267d39623d552de19664f000af9 Closes-bug: #1588793
This commit is contained in:
parent
b4ba7a3af1
commit
b5333c09ab
@ -52,7 +52,7 @@ def request_retry(codes):
|
||||
error_code = e.response.status_code
|
||||
if error_code in codes:
|
||||
if iter_number < codes[error_code]:
|
||||
wait = 5
|
||||
wait = 60
|
||||
if 'Retry-After' in e.response.headers:
|
||||
wait = int(e.response.headers['Retry-after'])
|
||||
logger.debug(log_msg.format(error_code, wait))
|
||||
@ -83,7 +83,8 @@ class APIClient(object):
|
||||
return self.__send_request('POST', uri, data)
|
||||
|
||||
def __send_request(self, method, uri, data):
|
||||
retry_codes = {429: 3}
|
||||
retry_codes = {429: 3,
|
||||
503: 10}
|
||||
|
||||
@request_retry(codes=retry_codes)
|
||||
def __get_response(_url, _headers, _data):
|
||||
|
Loading…
Reference in New Issue
Block a user