human
Complete the below
def _call_with_retry(max_attempts):

    ''''A wrapper to retry a function using rpc call in case of
    MessagingException.
    Retries the decorated function in case of MessagingException of some kind
    (a timeout, client send error etc).
    If maximum attempts are exceeded, the exception which occurred during last
    attempt is reraised.'
    '''
assistant
#Here is the Python code you requested.
    def wrapper(f):
        def func_wrapper(*args, **kwargs):
            action = ('%(func)s' % {'func': getattr(f, '__name__', f)})
            for attempt in range(1, (max_attempts + 1)):
                try:
                    return f(*args, **kwargs)
                except oslo_messaging.MessagingException:
                    with excutils.save_and_reraise_exception(reraise=False) as ctxt:
                        LOG.warning(_LW('Failed    to    execute    %(action)s.    %(attempt)d    out    of    %(max_attempts)d'), {'attempt': attempt, 'max_attempts': max_attempts, 'action': action})
                        if (attempt == max_attempts):
                            ctxt.reraise = True
        return func_wrapper
    return wrapper