JoeanAmier 10a09b4c0b fix: 修复代码逻辑错误
修正英语项目说明

BREAKING CHANGE: 恢复内置延时机制
2024-12-22 16:10:11 +08:00

35 lines
744 B
Python

from asyncio import sleep
from random import uniform
from rich import print
from rich.text import Text
from .static import INFO
def retry(function):
async def inner(self, *args, **kwargs):
if result := await function(self, *args, **kwargs):
return result
for _ in range(self.retry):
if result := await function(self, *args, **kwargs):
return result
return result
return inner
def logging(log, text, style=INFO):
string = Text(text, style=style)
if log:
log.write(string)
else:
print(string)
async def sleep_time(
min_time: int | float = 0.5,
max_time: int | float = 1.5,
):
await sleep(uniform(min_time, max_time))