aboutsummaryrefslogtreecommitdiffstats
path: root/botcore/_bot.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-04-05 16:09:31 +0100
committerGravatar Chris Lovering <[email protected]>2022-04-08 12:04:08 +0100
commit863e54f989d1c73a9c94113495dfa1404cff8b07 (patch)
treeebd76b73b9ee47db6577417b275db23cc7e78848 /botcore/_bot.py
parentMove the creation of BotBase._guild_available to within the setup hook (diff)
Create a dummy AsyncstatsdClient before connecting to the real url
This is in case a connection cannot be made on init.
Diffstat (limited to 'botcore/_bot.py')
-rw-r--r--botcore/_bot.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/botcore/_bot.py b/botcore/_bot.py
index f9e0b9fb..e69b056d 100644
--- a/botcore/_bot.py
+++ b/botcore/_bot.py
@@ -89,7 +89,11 @@ class BotBase(commands.Bot):
) -> None:
"""Callback used to retry a connection to statsd if it should fail."""
if attempt >= 8:
- log.error("Reached 8 attempts trying to reconnect AsyncStatsClient. Aborting")
+ log.error(
+ "Reached 8 attempts trying to reconnect AsyncStatsClient to %s. "
+ "Aborting and leaving the dummy statsd client in place.",
+ statsd_url,
+ )
return
try:
@@ -218,8 +222,9 @@ class BotBase(commands.Bot):
)
self.http.connector = self._connector
- self._connect_statsd(self.statsd_url, loop)
+ # Create dummy stats client first, in case `statsd_url` is unreachable within `_connect_statsd()`
self.stats = AsyncStatsClient(loop, "127.0.0.1")
+ self._connect_statsd(self.statsd_url, loop)
await self.stats.create_socket()
try: