diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a23061..ffc48ecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ 1. [#117](https://github.com/influxdata/influxdb-client-python/pull/117): Fixed appending default tags for single Point 1. [#115](https://github.com/influxdata/influxdb-client-python/pull/115): Fixed serialization of `\n`, `\r` and `\t` to Line Protocol, `=` is valid sign for measurement name 1. [#118](https://github.com/influxdata/influxdb-client-python/issues/118): Fixed serialization of DataFrame with empty (NaN) values +1. [#130](https://github.com/influxdata/influxdb-client-python/pull/130): Use `Retry-After` header value for Retryable error codes ## 1.8.0 [2020-06-19] diff --git a/influxdb_client/client/write_api.py b/influxdb_client/client/write_api.py index 75b7d114..8d52ad15 100644 --- a/influxdb_client/client/write_api.py +++ b/influxdb_client/client/write_api.py @@ -340,7 +340,11 @@ def _retry_handler(self, exception, source, data): if isinstance(exception, ApiException): if exception.status == 429 or exception.status == 503: - _delay = self._jitter_delay() + timedelta(milliseconds=self._write_options.retry_interval) + retry_interval = self._write_options.retry_interval + if exception.headers: + if "Retry-After" in exception.headers: + retry_interval = int(exception.headers.get("Retry-After")) * 1000 + _delay = self._jitter_delay() + timedelta(milliseconds=retry_interval) return self._retryable(data, delay=_delay) return rx.just(_BatchResponse(exception=exception, data=data)) diff --git a/tests/test_WriteApiBatching.py b/tests/test_WriteApiBatching.py index f58e0f21..a9381612 100644 --- a/tests/test_WriteApiBatching.py +++ b/tests/test_WriteApiBatching.py @@ -185,7 +185,7 @@ def test_jitter_interval(self): def test_retry_interval(self): httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=204) - httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=429) + httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=429, adding_headers={'Retry-After': '5'}) httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=503) self._write_client.write("my-bucket", "my-org", @@ -199,7 +199,7 @@ def test_retry_interval(self): self.assertEqual(2, len(httpretty.httpretty.latest_requests)) - time.sleep(3) + time.sleep(5) self.assertEqual(3, len(httpretty.httpretty.latest_requests)) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy