fix: 将所有后端文件都迁移到 sau_backend 文件夹内

This commit is contained in:
Edan's Win11
2025-06-03 15:28:08 +08:00
parent 794e8feaea
commit 5c91a68d8c
60 changed files with 73 additions and 72 deletions
-28
View File
@@ -1,28 +0,0 @@
import asyncio
import time
from functools import wraps
def async_retry(timeout=60, max_retries=None):
def decorator(func):
@wraps(func)
async def wrapper(*args, **kwargs):
start_time = time.time()
attempts = 0
while True:
try:
return await func(*args, **kwargs)
except Exception as e:
attempts += 1
if max_retries is not None and attempts >= max_retries:
print(f"Reached maximum retries of {max_retries}.")
raise Exception(f"Failed after {max_retries} retries.") from e
if time.time() - start_time > timeout:
print(f"Function timeout after {timeout} seconds.")
raise TimeoutError(f"Function execution exceeded {timeout} seconds timeout.") from e
print(f"Attempt {attempts} failed: {e}. Retrying...")
await asyncio.sleep(1) # Sleep to avoid tight loop or provide backoff logic here
return wrapper
return decorator