From a7122db250502453212c7b20528c23fac6de2cad Mon Sep 17 00:00:00 2001 From: EvB Date: Thu, 5 Jan 2017 11:31:21 -0500 Subject: [PATCH] fix(cloudwatch): randomize sleep interval --- util/saas/cloudwatch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/saas/cloudwatch.py b/util/saas/cloudwatch.py index 7f7fc3ad3..78e4abc11 100644 --- a/util/saas/cloudwatch.py +++ b/util/saas/cloudwatch.py @@ -1,6 +1,7 @@ import logging import boto import time +import random from Queue import Empty from threading import Thread @@ -82,7 +83,9 @@ class CloudWatchSender(Thread): logger.exception('Failed to write to CloudWatch: %s', metrics) logger.debug('Attempted to requeue %d metrics.', len(metrics['name'])) - time.sleep(FAILED_SEND_SLEEP_SECS) + # random int between 1/2 and 1 1/2 of FAILED_SEND_SLEEP duration + sleep_secs = random.randint(FAILED_SEND_SLEEP_SECS/2, 3*FAILED_SEND_SLEEP_SECS/2) + time.sleep(sleep_secs) def append_metric(metrics, m): name, value, kwargs = m