Skip to content

Commit e7ef045

Browse files
do not sleep after last retry before raising exception (influxdata#790)
* do not sleep after last retry before raising exception * documentation: clarification of retry parameter retry=0 - retry forever retry=1 - try once, on error don't do any retry retry=2 - 2 tries, one original and one retry on error retry=3 - 3 tries, one original and maximum two retries on errors * retries - move raise before sleep * retries - documentation * fix line length
1 parent cf83d1d commit e7ef045

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

influxdb/client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ class InfluxDBClient(object):
5959
:param timeout: number of seconds Requests will wait for your client to
6060
establish a connection, defaults to None
6161
:type timeout: int
62-
:param retries: number of retries your client will try before aborting,
63-
defaults to 3. 0 indicates try until success
62+
:param retries: number of attempts your client will make before aborting,
63+
defaults to 3
64+
0 - try until success
65+
1 - attempt only once (without retry)
66+
2 - maximum two attempts (including one retry)
67+
3 - maximum three attempts (default option)
6468
:type retries: int
6569
:param use_udp: use UDP to connect to InfluxDB, defaults to False
6670
:type use_udp: bool
@@ -339,10 +343,10 @@ def request(self, url, method='GET', params=None, data=None, stream=False,
339343
_try += 1
340344
if self._retries != 0:
341345
retry = _try < self._retries
342-
if method == "POST":
343-
time.sleep((2 ** _try) * random.random() / 100.0)
344346
if not retry:
345347
raise
348+
if method == "POST":
349+
time.sleep((2 ** _try) * random.random() / 100.0)
346350

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

0 commit comments

Comments
 (0)