From 7ee4000ee083f71eec2a2f85a9f1acaeaf88f1d1 Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Thu, 28 Dec 2023 17:58:49 +0000 Subject: [PATCH] Laura: Fix awaitable error 4d03d6e16e4b2ada63a186061ab618fbb5f256ff --- slixfeed/task.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/slixfeed/task.py b/slixfeed/task.py index c048949..6f4b016 100644 --- a/slixfeed/task.py +++ b/slixfeed/task.py @@ -361,11 +361,14 @@ async def refresh_task(self, jid, callback, key, val=None): task_manager[jid][key].cancel() except: print("No task of type", key, "to cancel for JID", jid) - task_manager[jid][key] = loop.call_at( - loop.time() + 60 * float(val), - loop.create_task, - (callback(self, jid)) - # send_update(jid) + # task_manager[jid][key] = loop.call_at( + # loop.time() + 60 * float(val), + # loop.create_task, + # (callback(self, jid)) + # # send_update(jid) + # ) + task_manager[jid][key] = loop.create_task( + wait_and_run(self, callback, jid, val) ) # task_manager[jid][key] = loop.call_later( # 60 * float(val), @@ -379,6 +382,11 @@ async def refresh_task(self, jid, callback, key, val=None): # ) +async def wait_and_run(self, callback, jid, val): + await asyncio.sleep(60 * float(val)) + await callback(self, jid) + + # TODO Take this function out of # async def check_updates(jid):