Team Ai
Apppublic

cactus183/patchbench-dev

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
buggy_code.py18 linesDownload Raw Back to medium_03
1import time2 3 4def retry_with_backoff(max_retries=3, base_delay=0.01):5    """Decorator that retries a function on exception with exponential backoff."""6    def decorator(func):7        def wrapper(*args, **kwargs):8            attempts = 09            while attempts < max_retries:10                try:11                    return func(*args, **kwargs)12                except Exception:13                    attempts += 114                    time.sleep(base_delay)  # BUG: should be base_delay * (2 ** attempts)15            return func(*args, **kwargs)  # BUG: extra unguarded call instead of raising last exception16        return wrapper17    return decorator18