mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-04-11 11:41:59 -04:00
...
This commit is contained in:
parent
99c49f4df1
commit
ece6f7ea6b
@ -29,17 +29,15 @@ def retry(max_attempts=3, delay=0):
|
||||
def decorator(test_func):
|
||||
@wraps(test_func)
|
||||
def wrapper(*args, **kwargs):
|
||||
last_exception = None
|
||||
for attempt in range(max_attempts):
|
||||
try:
|
||||
return test_func(*args, **kwargs)
|
||||
except AssertionError as e:
|
||||
last_exception = e
|
||||
if attempt < max_attempts - 1:
|
||||
print(f'Retry ({attempt + 1}/{max_attempts-1}) on {test_func} failure with error: {e}')
|
||||
time.sleep(delay)
|
||||
print(f'Retry {attempt + 1}/{max_attempts - 1}')
|
||||
else:
|
||||
raise last_exception
|
||||
raise
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user