From ca761f04eb3353ae4e9a992d23d13d131d5a6ad0 Mon Sep 17 00:00:00 2001 From: Thomas Petersson Date: Mon, 5 Oct 2020 19:30:58 +0200 Subject: fix(bot): Not assign stats to None self.stats is referred to as bot.stats in the project, which was overlooked. This should "disable" stats until it's successfully reconnected. The retry attempts will continue until it stops throwing or fails 10x --- bot/bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/bot.py b/bot/bot.py index 0b842d07a..545efefe6 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -15,6 +15,7 @@ from bot import DEBUG_MODE, api, constants from bot.async_stats import AsyncStatsClient log = logging.getLogger('bot') +LOCALHOST = "127.0.0.1" class Bot(commands.Bot): @@ -44,12 +45,12 @@ class Bot(commands.Bot): # Since statsd is UDP, there are no errors for sending to a down port. # For this reason, setting the statsd host to 127.0.0.1 for development # will effectively disable stats. - statsd_url = "127.0.0.1" + statsd_url = LOCALHOST try: self.stats = AsyncStatsClient(self.loop, statsd_url, 8125, prefix="bot") except socket.gaierror as socket_error: - self.stats = None + self.stats = AsyncStatsClient(self.loop, LOCALHOST) self.loop.call_later(30, self.retry_statsd_connection, statsd_url) log.warning(f"Statsd client failed to instantiate with error:\n{socket_error}") -- cgit v1.2.3