that is, the argument signature is preserved perfectly and we see our load_user_info function acting identically as its non-cached version.
The old behavior looked like this:
FullArgSpec(args=['value'], varargs=None, varkw=None, defaults=(0,), kwonlyargs=[], kwonlydefaults=None, annotations={})
FullArgSpec(args=[], varargs='arg', varkw='kw', defaults=None, kwonlyargs=[], kwonlydefaults=None, annotations={})
Traceback (most recent call last):
File "test.py", line 21, in <module>
print(load_user_info(value=5))
File "/home/classic/dev/dogpile.cache/dogpile/cache/region.py", line 1262, in decorate
key = key_generator(*arg, **kw)
File "/home/classic/dev/dogpile.cache/dogpile/cache/util.py", line 37, in generate_key
"dogpile.cache's default key creation "
ValueError: dogpile.cache's default key creation function does not accept keyword arguments.
this is because the argument signature was blown away so that the arg/kw were passed generically. you can still get the ValueError if you add `**kw` to the argument signature for load_user_info() and then add some extra keywords.
in short I think oslo.cache can remove the test case here as indicated in https://review.openstack.org/#/c/638732/, because you are not only testing dogpile, you're testing plain python / the decorator module.
I've added https:/ /github. com/sqlalchemy/ dogpile. cache/issues/ 144 to review this behavior and while 0.7's behavior is different, I think it is better:
from dogpile.cache import make_region
region = make_region( ).configure( cache.memory' ,
'dogpile.
)
def load_user_ info(value= 0):
return "hi"
import inspect
print(inspect. getfullargspec( load_user_ info))
load_user_info = region. cache_on_ arguments( )(load_ user_info)
print(inspect. getfullargspec( load_user_ info))
print(load_ user_info( value=5) )
the above script in 0.7.x prints:
FullArgSpec( args=[' value'] , varargs=None, varkw=None, defaults=(0,), kwonlyargs=[], kwonlydefaults= None, annotations={}) args=[' value'] , varargs=None, varkw=None, defaults=(0,), kwonlyargs=[], kwonlydefaults= None, annotations={})
FullArgSpec(
hi
that is, the argument signature is preserved perfectly and we see our load_user_info function acting identically as its non-cached version.
The old behavior looked like this:
FullArgSpec( args=[' value'] , varargs=None, varkw=None, defaults=(0,), kwonlyargs=[], kwonlydefaults= None, annotations={}) args=[] , varargs='arg', varkw='kw', defaults=None, kwonlyargs=[], kwonlydefaults= None, annotations={}) load_user_ info(value= 5)) classic/ dev/dogpile. cache/dogpile/ cache/region. py", line 1262, in decorate classic/ dev/dogpile. cache/dogpile/ cache/util. py", line 37, in generate_key cache's default key creation "
FullArgSpec(
Traceback (most recent call last):
File "test.py", line 21, in <module>
print(
File "/home/
key = key_generator(*arg, **kw)
File "/home/
"dogpile.
ValueError: dogpile.cache's default key creation function does not accept keyword arguments.
this is because the argument signature was blown away so that the arg/kw were passed generically. you can still get the ValueError if you add `**kw` to the argument signature for load_user_info() and then add some extra keywords.
in short I think oslo.cache can remove the test case here as indicated in https:/ /review. openstack. org/#/c/ 638732/, because you are not only testing dogpile, you're testing plain python / the decorator module.