From fa8231eb711c04a276eee27e00b9aba21d5cbc28 Mon Sep 17 00:00:00 2001 From: phxntxm Date: Wed, 31 Aug 2016 23:46:22 -0500 Subject: [PATCH] Added another check in case cached object failed --- cogs/utils/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cogs/utils/config.py b/cogs/utils/config.py index caa2132..bd4f3d7 100644 --- a/cogs/utils/config.py +++ b/cogs/utils/config.py @@ -135,7 +135,8 @@ async def get_content(key: str): # We want to check here if the key exists in cache, and it was not created more than an hour ago # We also want to make sure that if what we're getting in cache has content # if not, lets make sure something didn't go awry, by getting from the database instead - if cached is None or len(cached.values) == 0 or (pendulum.utcnow() - cached.refreshed).hours >= 1: + if cached is None or isinstance(cached, {}) or len(cached.values) == 0 or ( + pendulum.utcnow() - cached.refreshed).hours >= 1: value = await _get_content(key) # If we found this object not cached, cache it cache[key] = value @@ -143,6 +144,7 @@ async def get_content(key: str): value = cached.values return value + # This is our internal method to get content from the database async def _get_content(key: str): # We need to make sure we're using asyncio