Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

retry on HTTPError exceptions need raise_for_status()? #832

Open
@loopway

Description

@loopway

We occasionally receive a http status 500 code (time out) from our influxdb instance, probably because of temporary peak load. Looking at the retry code in InfluxDBClient class I can see that you try to catch HTTPErrors (line 345):

# Try to send the request more than once by default (see #103)
retry = True
_try = 0
while retry:
try:
response = self._session.request(
method=method,
url=url,
auth=(self._username, self._password),
params=params,
data=data,
stream=stream,
headers=headers,
proxies=self._proxies,
verify=self._verify_ssl,
timeout=self._timeout
)
break
except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError,
requests.exceptions.Timeout):
_try += 1
if self._retries != 0:
retry = _try < self._retries
if not retry:
raise
if method == "POST":
time.sleep((2 ** _try) * random.random() / 100.0)

According to the requests library documentation a raise_for_status() is needed for the exception to be caught:

https://requests.readthedocs.io/en/master/user/quickstart/#errors-and-exceptions

Or am I missing something?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions