diff options
author | 2022-04-18 15:44:22 +0100 | |
---|---|---|
committer | 2022-04-18 16:12:59 +0100 | |
commit | aca37f50e11f261a7d914e5b5471b2717b51e5c8 (patch) | |
tree | 4470bc87711d79de0be2680b52a618005c86f1c4 /botcore | |
parent | Bump version number and log change (diff) |
Reconnect to redis session on setup if it is closed
Diffstat (limited to 'botcore')
-rw-r--r-- | botcore/_bot.py | 7 |
1 files changed, 6 insertions, 1 deletions
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: |