From ce22d44a869473308acd17eb9bda7dadb4400735 Mon Sep 17 00:00:00 2001 From: phxntxm Date: Fri, 16 Jun 2017 03:47:49 -0500 Subject: [PATCH] Change the creation of the refreshing task, since call_later can't be used with coroutines --- cogs/utils/database.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cogs/utils/database.py b/cogs/utils/database.py index 944708d..2898989 100644 --- a/cogs/utils/database.py +++ b/cogs/utils/database.py @@ -29,12 +29,16 @@ class Cache: self.loop = loop self.values = [] # The values returned from the database self.refreshed_time = None - self.loop.create_task(self.check_refresh()) + self.loop.create_task(self.refresh_task()) async def refresh(self): self.values = await self.db.actual_load(self.table) self.refreshed_time = datetime.now() + async def refresh_task(self): + await self.check_refresh() + await asyncio.sleep(60) + async def check_refresh(self): if self.refreshed_time is None: await self.refresh() @@ -43,8 +47,6 @@ class Cache: if difference.total_seconds() > 300: await self.refresh() - self.loop.call_later(60, self.check_refresh()) - def get(self, key=None, table_filter=None, pluck=None): """This simulates the database call, to make it easier to get the data""" if key is None and table_filter is None: