From e661ab01d7bb0dde366653a78b535bb5308c2200 Mon Sep 17 00:00:00 2001 From: Hrithik-ui753 Date: Tue, 26 May 2026 16:40:05 +0530 Subject: [PATCH] fix(core): fix async_wrapper typo in retry decorator (#230) --- core/utils/retry.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/utils/retry.py b/core/utils/retry.py index 9dc58a3..036e59c 100644 --- a/core/utils/retry.py +++ b/core/utils/retry.py @@ -8,6 +8,7 @@ logger = logging.getLogger(__name__) +# Configure a clean file logging mechanism without side effects if not logger.handlers: handler = logging.FileHandler("retry.log") formatter = logging.Formatter( @@ -17,10 +18,14 @@ logger.addHandler(handler) logger.setLevel(logging.WARNING) -logging.basicConfig(filename="retry.log", level=logging.WARNING) def retry(max_retries: int = 3, base_delay: float = 1.0): + """ + Decorator to automatically retry both sync and async functions + upon hitting OpenAI API or Rate Limit errors with exponential backoff. + """ def decorator(func): + # Handle Asynchronous Functions if inspect.iscoroutinefunction(func): @wraps(func) @@ -43,6 +48,7 @@ async def async_wrapper(*args, **kwargs): return async_wrapper + # Handle Synchronous Functions else: @wraps(func) @@ -65,4 +71,4 @@ def sync_wrapper(*args, **kwargs): return sync_wrapper - return decorator + return decorator \ No newline at end of file