aboutsummaryrefslogtreecommitdiffstats
path: root/botcore/_bot.py
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-04-18 16:57:44 +0100
committerGravatar GitHub <[email protected]>2022-04-18 16:57:44 +0100
commit1ca68b789a9a62a46686c5704753cf4d0f29c758 (patch)
tree72617275475175d2aefc853d839483e8b43da426 /botcore/_bot.py
parentMerge pull request #57 from python-discord/dependabot/pip/furo-2022.4.7 (diff)
parentBump version number and log change (diff)
Merge pull request #56 from python-discord/minor-fixes-to-BotBase
Minor fixes to BotBase
Diffstat (limited to 'botcore/_bot.py')
-rw-r--r--botcore/_bot.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/botcore/_bot.py b/botcore/_bot.py
index 6486670d..e69b056d 100644
--- a/botcore/_bot.py
+++ b/botcore/_bot.py
@@ -74,7 +74,7 @@ class BotBase(commands.Bot):
self.statsd_url: Optional[str] = None
self._statsd_timerhandle: Optional[asyncio.TimerHandle] = None
- self._guild_available = asyncio.Event()
+ self._guild_available: Optional[asyncio.Event] = None
self.stats: Optional[AsyncStatsClient] = None
@@ -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:
@@ -209,6 +213,8 @@ class BotBase(commands.Bot):
"""
loop = asyncio.get_running_loop()
+ self._guild_available = asyncio.Event()
+
self._resolver = aiohttp.AsyncResolver()
self._connector = aiohttp.TCPConnector(
resolver=self._resolver,
@@ -216,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: