aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Thomas Petersson <[email protected]>2020-10-05 19:30:58 +0200
committerGravatar Thomas Petersson <[email protected]>2020-10-05 19:30:58 +0200
commitca761f04eb3353ae4e9a992d23d13d131d5a6ad0 (patch)
tree6421122c452c419c74cce1b785e46cc7d50f1f98
parentfix(statsd): Gracefully handle gaierro (diff)
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
-rw-r--r--bot/bot.py5
1 files 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}")