Skip to content

Commit

Permalink
Retry backend request on 502 return
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed May 31, 2024
1 parent 9dfa7fa commit d24db79
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions neon_utils/hana_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,14 @@ def request_backend(endpoint: str, request_data: dict,
except ServerException as e:
LOG.error(e)
_get_token(server_url)
resp = requests.post(f"{server_url}/{endpoint.lstrip('/')}",
json=request_data, headers=_headers)
request_kwargs = {"url": f"{server_url}/{endpoint.lstrip('/')}",
"json": request_data, "headers": _headers}
resp = requests.post(**request_kwargs)
if resp.status_code == 502:
# This is raised occasionally on valid requests. Need to resolve in HANA
resp = requests.post(**request_kwargs)
if resp.ok:
return resp.json()

else:
raise ServerException(f"Error response {resp.status_code}: {resp.text}")

0 comments on commit d24db79

Please sign in to comment.