From 2335970a790a73544565ae0472403fbac8271fe5 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 5 Apr 2022 16:08:48 +0100 Subject: Move the creation of BotBase._guild_available to within the setup hook This is to avoid a deprecation notice. --- botcore/_bot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/botcore/_bot.py b/botcore/_bot.py index 6486670d..f9e0b9fb 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 @@ -209,6 +209,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, -- cgit v1.2.3 From 863e54f989d1c73a9c94113495dfa1404cff8b07 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 5 Apr 2022 16:09:31 +0100 Subject: Create a dummy AsyncstatsdClient before connecting to the real url This is in case a connection cannot be made on init. --- botcore/_bot.py | 9 +++++++-- 1 file 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: -- cgit v1.2.3 From 5935159fed252dc17a60d53ed367b4a12e8386a4 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 5 Apr 2022 16:09:43 +0100 Subject: Bump version number and log change --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b041bad6..3779ad32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 5.0.2 5th April 2022 +- Fix: Create a dummy `AsyncstatsdClient` before connecting to real url, in case a connection cannot be made on init. +- Fix: Move the creation of the `asyncio.Event`, `BotBase._guild_available` to within the setup hook, to avoid a deprecation notice. + +## 5.0.1 2nd April 2022 +- Fix: Move creation of BotBase's `aiohttp.AsyncResolver` to the async setup hook, to avoid deprecation notice + ## 5.0.0 2nd April 2022 - Breaking: Remove public extensions util - Feature: Add `BotBase`, a `discord.ext.commands.Bot` sub-class, which abstracts a lot of logic shared between our bots diff --git a/pyproject.toml b/pyproject.toml index 4561706f..76f0e667 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bot-core" -version = "5.0.1" +version = "5.0.2" description = "Bot-Core provides the core functionality and utilities for the bots of the Python Discord community." authors = ["Python Discord "] license = "MIT" -- cgit v1.2.3