aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--botcore/_bot.py7
-rw-r--r--pyproject.toml2
3 files changed, 10 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3779ad32..f78ef928 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## 5.0.3 18th April 2022
+- Fix: Reconnect to redis session on setup if it is closed.
+
## 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.
diff --git a/botcore/_bot.py b/botcore/_bot.py
index e69b056d..69ccdc1c 100644
--- a/botcore/_bot.py
+++ b/botcore/_bot.py
@@ -222,6 +222,11 @@ class BotBase(commands.Bot):
)
self.http.connector = self._connector
+ if getattr(self, "redis_session", False) and self.redis_session.closed:
+ # If the RedisSession was somehow closed, we try to reconnect it
+ # here. Normally, this shouldn't happen.
+ await self.redis_session.connect()
+
# 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)
@@ -265,7 +270,7 @@ class BotBase(commands.Bot):
if self.stats._transport:
self.stats._transport.close()
- if getattr(self.redis_session, None):
+ if getattr(self, "redis_session", False):
await self.redis_session.close()
if self._statsd_timerhandle:
diff --git a/pyproject.toml b/pyproject.toml
index 76f0e667..1ad6edd9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bot-core"
-version = "5.0.2"
+version = "5.0.3"
description = "Bot-Core provides the core functionality and utilities for the bots of the Python Discord community."
authors = ["Python Discord <[email protected]>"]
license = "MIT"