human
I wrote the below code

    def decorator(f):
        try:
            ctx_arg_index = p_util.getargspec(f).args.index(context_var_name)
        except ValueError:
            raise RuntimeError((_LE('Could    not    find    position    of    var    %s') % context_var_name))
        f_with_retry = retry_db_errors(f)
        @six.wraps(f)
        def wrapped(*args, **kwargs):
            if (context_var_name in kwargs):
                context = kwargs[context_var_name]
            else:
                context = args[ctx_arg_index]
            method = (f if context.session.is_active else f_with_retry)
            return method(*args, **kwargs)
        return wrapped
    return decorator

What's a good function header?
assistant
#Here is Python program to find    position    of    var    %s') % context_var_name))
.

def retry_if_session_inactive(context_var_name='context'):