aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/bot.py5
-rw-r--r--bot/utils/redis_cache.py3
2 files changed, 6 insertions, 2 deletions
diff --git a/bot/bot.py b/bot/bot.py
index f1365d532..ba09ce207 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -32,6 +32,7 @@ class Bot(commands.Bot):
self.http_session: Optional[aiohttp.ClientSession] = None
self.redis_session: Optional[aioredis.Redis] = None
self.redis_ready = asyncio.Event()
+ self.redis_closed = False
self.api_client = api.APIClient(loop=self.loop)
self._connector = None
@@ -106,8 +107,9 @@ class Bot(commands.Bot):
self.stats._transport.close()
if self.redis_session:
- self.redis_ready.clear()
+ self.redis_closed = True
self.redis_session.close()
+ self.redis_ready.clear()
await self.redis_session.wait_closed()
async def login(self, *args, **kwargs) -> None:
@@ -135,6 +137,7 @@ class Bot(commands.Bot):
# Create the redis session
self.loop.create_task(self._create_redis_session())
+ self.redis_closed = False
# Use AF_INET as its socket family to prevent HTTPS related problems both locally
# and in production.
diff --git a/bot/utils/redis_cache.py b/bot/utils/redis_cache.py
index 6b3c68979..de80cee84 100644
--- a/bot/utils/redis_cache.py
+++ b/bot/utils/redis_cache.py
@@ -173,7 +173,8 @@ class RedisCache:
log.error(error_message)
raise NoBotInstanceError(error_message)
- await self.bot.redis_ready.wait()
+ if not self.bot.redis_closed:
+ await self.bot.redis_ready.wait()
def __set_name__(self, owner: Any, attribute_name: str) -> None:
"""