From 2ac5749e7c6ad480515a33685067514c417a4bb4 Mon Sep 17 00:00:00 2001 From: Krzysztof Baranski Date: Wed, 26 Feb 2020 22:53:02 +0100 Subject: [PATCH 1/5] do not sleep after last retry before raising exception --- influxdb/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/client.py b/influxdb/client.py index 5e39f490..26d654c2 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -292,7 +292,7 @@ def request(self, url, method='GET', params=None, data=None, _try += 1 if self._retries != 0: retry = _try < self._retries - if method == "POST": + if retry and method == "POST": time.sleep((2 ** _try) * random.random() / 100.0) if not retry: raise From 46cd2f941f04af17aa970ff5e968d250d614f4a5 Mon Sep 17 00:00:00 2001 From: Krzysztof Baranski Date: Wed, 26 Feb 2020 23:07:15 +0100 Subject: [PATCH 2/5] 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 --- influxdb/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/influxdb/client.py b/influxdb/client.py index 26d654c2..4de4092b 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -53,8 +53,11 @@ 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, + :param retries: how many times your client will try before aborting, defaults to 3. 0 indicates try until success + For example: + 1 - try only once (without retry), + 2 - maximum two tries (including one retry) :type retries: int :param use_udp: use UDP to connect to InfluxDB, defaults to False :type use_udp: bool From 6f3855241fb8775b40fb1231804fe9da220be6e2 Mon Sep 17 00:00:00 2001 From: Krzysztof Baranski Date: Sat, 11 Apr 2020 14:28:03 +0200 Subject: [PATCH 3/5] retries - move raise before sleep --- influxdb/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/influxdb/client.py b/influxdb/client.py index 4de4092b..01dec023 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -295,10 +295,10 @@ def request(self, url, method='GET', params=None, data=None, _try += 1 if self._retries != 0: retry = _try < self._retries - if retry and 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: From 13ce47763d819d1c8854cf5a79a15d725e522e30 Mon Sep 17 00:00:00 2001 From: Krzysztof Baranski Date: Sat, 11 Apr 2020 14:28:45 +0200 Subject: [PATCH 4/5] retries - documentation --- influxdb/client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/influxdb/client.py b/influxdb/client.py index 01dec023..37dfb4b2 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -53,11 +53,11 @@ 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: how many times your client will try before aborting, - defaults to 3. 0 indicates try until success - For example: - 1 - try only once (without retry), - 2 - maximum two tries (including one retry) + :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 From 9ebdf36fd318e720868bc07db209b6aebb2278a7 Mon Sep 17 00:00:00 2001 From: Krzysztof Baranski Date: Sat, 11 Apr 2020 15:00:10 +0200 Subject: [PATCH 5/5] fix line length --- influxdb/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/influxdb/client.py b/influxdb/client.py index 37dfb4b2..f248596b 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -53,7 +53,8 @@ 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 attempts your client will make before aborting, defaults to 3 + :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)