Skip to content

Instantly share code, notes, and snippets.

@FernandoCelmer
Created December 10, 2024 06:24
Show Gist options
  • Select an option

  • Save FernandoCelmer/217444f57ba72cf25c6593f842f557c0 to your computer and use it in GitHub Desktop.

Select an option

Save FernandoCelmer/217444f57ba72cf25c6593f842f557c0 to your computer and use it in GitHub Desktop.
Retry
def retry(max_retry):
def inside(func):
def wrapper(*args, **kwargs):
attempt = 0
error_output = None
while max_retry > attempt:
try:
return func(*args, **kwargs)
except Exception as error:
error_output = error
attempt += 1
log_exception(error_output)
raise error_output
return wrapper
return inside
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment