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

do not sleep after last retry before raising exception #790

Merged
merged 5 commits into from
Apr 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ class InfluxDBClient(object):
:param timeout: number of seconds Requests will wait for your client to
establish a connection, defaults to None
:type timeout: int
:param retries: number of retries your client will try before aborting,
defaults to 3. 0 indicates try until success
:param retries: number of attempts your client will make before aborting,
defaults to 3
0 - try until success
1 - attempt only once (without retry)
2 - maximum two attempts (including one retry)
3 - maximum three attempts (default option)
:type retries: int
:param use_udp: use UDP to connect to InfluxDB, defaults to False
:type use_udp: bool
Expand Down Expand Up @@ -292,10 +296,10 @@ def request(self, url, method='GET', params=None, data=None,
_try += 1
if self._retries != 0:
retry = _try < self._retries
if method == "POST":
time.sleep((2 ** _try) * random.random() / 100.0)
if not retry:
raise
if method == "POST":
time.sleep((2 ** _try) * random.random() / 100.0)

type_header = response.headers and response.headers.get("Content-Type")
if type_header == "application/x-msgpack" and response.content:
Expand Down