This repository was archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 522
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
Copy link
Copy link
Open
Labels
Description
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):
influxdb-python/influxdb/client.py
Lines 326 to 353 in fc0235e
# 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?