Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with decorate>=5.0.5 in dogpile.cache.region #208

Open
osfrickler opened this issue Aug 14, 2021 · 3 comments
Open

Issue with decorate>=5.0.5 in dogpile.cache.region #208

osfrickler opened this issue Aug 14, 2021 · 3 comments
Labels
bug Something isn't working region

Comments

@osfrickler
Copy link

The latest releases of decorate changed the handling of positional args in some cases, see micheles/decorator@04bb645. This is triggering failures in some consumers, e.g. openstacksdk, see https://storyboard.openstack.org/#!/story/2009114 and micheles/decorator#127. What works for me in local unit testing is adding the kwsyntax=True option like

diff --git a/dogpile/cache/region.py b/dogpile/cache/region.py
index ef0dbc4..561e208 100644
--- a/dogpile/cache/region.py
+++ b/dogpile/cache/region.py
@@ -1619,7 +1619,7 @@ class CacheRegion:
             # Use `decorate` to preserve the signature of :param:`user_func`.
 
             return decorate(
-                user_func, partial(get_or_create_for_user_func, key_generator)
+                user_func, partial(get_or_create_for_user_func, key_generator), kwsyntax=True
             )
 
         return cache_decorator
@@ -1859,7 +1859,7 @@ class CacheRegion:
             # Use `decorate` to preserve the signature of :param:`user_func`.
 
             return decorate(
-                user_func, partial(get_or_create_for_user_func, key_generator)
+                user_func, partial(get_or_create_for_user_func, key_generator), kwsyntax=True
             )
 
         return cache_decorator

But maybe there is also a way to adopt to the new behaviour more smoothly. The above patch will break when using an old version of decorate and I don't know whether there's a better solution then wrapping in a try block and repeating the call without the added option if necessary.

@osfrickler
Copy link
Author

Hmm, the above patch is breaking tests/cache/test_region.py::AsyncCreatorTest::test_fn_decorator_with_kw, so I would also not exclude the possibility that it's actually the code in openstacksdk that's broken.

@zzzeek
Copy link
Member

zzzeek commented Aug 14, 2021

cc @4383

@zzzeek zzzeek added bug Something isn't working region labels Aug 14, 2021
@zzzeek
Copy link
Member

zzzeek commented Aug 14, 2021

any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working region
Projects
None yet
Development

No branches or pull requests

2 participants