From 60d83b3022fc5904efda2bdc915dae6360563346 Mon Sep 17 00:00:00 2001 From: retoor Date: Mon, 25 Nov 2024 20:39:06 +0100 Subject: [PATCH] Made get rants async. --- src/drstats/sync.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drstats/sync.py b/src/drstats/sync.py index 7145bde..75709ac 100644 --- a/src/drstats/sync.py +++ b/src/drstats/sync.py @@ -25,9 +25,15 @@ def timestamp_to_string(timestamp): async def get_recent_rants(start_from=1, page_size=10): + loop = asyncio.get_running_loop() page = 0 while True: - rants = dr.get_rants("recent", page_size, start_from)["rants"] + + def get_rants(): + return dr.get_rants("recent", page_size, start_from)["rants"] + + rants = asyncio.wait_for(asyncio.run_in_executor(get_rants), 5) + page += 1 for rant in rants: if rant is None: