util.secscan.api: failover connection failures
This commit is contained in:
parent
eac9927414
commit
c8034deab4
1 changed files with 7 additions and 4 deletions
|
@ -371,7 +371,10 @@ def _join_api_url(endpoint, api_version, path):
|
|||
@failover
|
||||
def _failover_read_request(request_fn, endpoint, path, body, params, timeout):
|
||||
""" This function auto-retries read-only requests until they return a 2xx status code. """
|
||||
resp = request_fn('GET', endpoint, path, body, params, timeout)
|
||||
if resp.status_code / 100 != 2:
|
||||
raise FailoverException(resp, 'status code was not 2xx')
|
||||
return resp
|
||||
try:
|
||||
resp = request_fn('GET', endpoint, path, body, params, timeout)
|
||||
if resp.status_code / 100 != 2:
|
||||
raise FailoverException(resp, 'status code was not 2xx')
|
||||
return resp
|
||||
except requests.exceptions.RequestException:
|
||||
raise FailoverException(None, 'connection failure')
|
||||
|
|
Reference in a new issue