diff --git a/shade/_utils.py b/shade/_utils.py index 3ca54d128..9cf566d67 100644 --- a/shade/_utils.py +++ b/shade/_utils.py @@ -14,6 +14,7 @@ import contextlib import fnmatch +import functools import inspect import jmespath import munch @@ -414,6 +415,18 @@ def valid_kwargs(*valid_args): return func_wrapper +def _func_wrap(f): + # NOTE(morgan): This extra wrapper is intended to eliminate ever + # passing a bound method to dogpile.cache's cache_on_arguments. In + # 0.7.0 and later it is impossible to pass bound methods to the + # decorator. This was introduced when utilizing the decorate module in + # lieu of a direct wrap implementation. + @functools.wraps(f) + def inner(*args, **kwargs): + return f(*args, **kwargs) + return inner + + def cache_on_arguments(*cache_on_args, **cache_on_kwargs): _cache_name = cache_on_kwargs.pop('resource', None) @@ -421,7 +434,7 @@ def cache_on_arguments(*cache_on_args, **cache_on_kwargs): def _cache_decorator(obj, *args, **kwargs): the_method = obj._get_cache(_cache_name).cache_on_arguments( *cache_on_args, **cache_on_kwargs)( - func.__get__(obj, type(obj))) + _func_wrap(func.__get__(obj, type(obj)))) return the_method(*args, **kwargs) def invalidate(obj, *args, **kwargs):