Fix dogpile.cache 0.7.0 interaction
Due to the change in behavior in dogpile.cache > 0.7.0 where bound methods can no longer be passed to the cache_on_arguments decorator, openstackSDK now explicitly provides a non-method wrapper for all elements passed to cache_on_arguments. This is handled via an explicit no-op decorator. functools.wraps is used to preserve data from the original method. Needed-By: https://review.openstack.org/#/c/624993 Change-Id: Ied27fa1e834d145246815afcb67c59d48669ffb2 Story: 2004605 Task: 28502
This commit is contained in:
parent
e54e3b0cca
commit
b23000c660
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user