From df55ac6d75a0aa14c5647bbfce98dcaef38bc86e Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Fri, 19 Feb 2021 15:16:10 +0100 Subject: [PATCH] Add stop condition and fix comment --- gnocchi/incoming/redis.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gnocchi/incoming/redis.py b/gnocchi/incoming/redis.py index 5c2e33f51..28859fc77 100644 --- a/gnocchi/incoming/redis.py +++ b/gnocchi/incoming/redis.py @@ -96,9 +96,10 @@ def add_measures_batch(self, metrics_and_measures): notified_sacks.add(sack_name) pipe.execute() + # if ConnectionError exception occurs, try again, max 5 times. @tenacity.retry( wait=utils.wait_exponential, - # Never retry except when explicitly asked by raising TryAgain + stop=tenacity.stop_after_attempt(5), retry=tenacity.retry_if_exception_type(ConnectionError)) def _build_report(self, details): report_vars = {'measures': 0, 'metric_details': {}} @@ -183,9 +184,10 @@ def process_measures_for_sack(self, sack): pipe.ltrim(key, item_len + 1, -1) pipe.execute() + # if ConnectionError exception occurs, try again, max 5 times. @tenacity.retry( wait=utils.wait_exponential, - # Never retry except when explicitly asked by raising TryAgain + stop=tenacity.stop_after_attempt(5), retry=tenacity.retry_if_exception_type(ConnectionError)) def iter_on_sacks_to_process(self): self._client.config_set("notify-keyspace-events", "K$")