Track bundled vendor runtime sources
Some checks failed
CI / main (push) Has been cancelled
CI / release-e2e (push) Has been cancelled

This commit is contained in:
2026-07-07 10:05:50 +08:00
parent fbe179ab53
commit 52636c91ae
2111 changed files with 1850012 additions and 14 deletions

View File

@@ -0,0 +1,28 @@
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