feat: make get_recent_rants async by wrapping dr.get_rants in run_in_executor with 5s timeout

This commit is contained in:
retoor 2024-11-25 19:39:06 +00:00
parent c32c59dd2a
commit a6fd640e92

View File

@ -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: