def METHOD_NAME(*args, **kwargs):
    max_retries = kwargs.pop('max_retries', 3)
    for retries in range(max_retries):
        try:
            return fun(*args, **kwargs)
        except (DatabaseError, InvalidRequestError, StaleDataError):
            logger.warning(
                'Failed operation %s.  Retrying %s more times.',
                fun.__name__, max_retries - retries - 1,
                exc_info=True)
            if retries + 1 >= max_retries:
                raise