util.secscan.api: failover connection failures

This commit is contained in:
Jimmy Zelinskie 2017-02-23 15:01:32 -05:00
parent eac9927414
commit c8034deab4

View file

@ -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')