code: def retry(default=None):
      
  
      def decorator(func):
          """Retry decorator"""
  
          @functools.wraps(func)
          def _wrapper(*args, **kw):
              for pos in range(1, MAX_RETRIES):
                  try:
                      return func(*args, **kw)
                  except (RuntimeError, requests.ConnectionError) as error:
                      LOGGER.warning("Failed: %s, %s", type(error), error)
  
                  # Wait a bit before retrying
                  for _ in range(pos):
                      _rest()
  
              LOGGER.warning("Request Aborted")
              return default
  
          return _wrapper
  
      return decorator
docs: Retry functions after failures