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 instance context within the synchronized decorator #145

Closed
daniel-o-jones opened this issue Jan 6, 2020 · 4 comments · Fixed by #146
Closed

issue with instance context within the synchronized decorator #145

daniel-o-jones opened this issue Jan 6, 2020 · 4 comments · Fixed by #146

Comments

@daniel-o-jones
Copy link
Contributor

I've run into an issue using wrapt's synchronized decorator

Previous behaviour and comment in the _synchronized_wrapper function implies the instance has to be None before wrapped is used as the context in the _synchronized_lock function. But the way it's working now means that a Falsey (but not None) instance isn't getting used as the context

Changing line 499 to with _synchronized_lock(instance if instance is not None else wrapped): is a one line solution of the problem that works for our use case

@GrahamDumpleton
Copy link
Owner

Yep. Am curious though as to what type of object you were applying it to that you hit that. An instance of some custom type of your own, or something from a third party library?

@GrahamDumpleton
Copy link
Owner

Add test and change notes in 0c98567

@GrahamDumpleton
Copy link
Owner

Note that I will probably only release a new version in a week or so. Am about to be travelling for a bit and don't want to do it right now as internet access the next week may be unpredictable.

@daniel-o-jones
Copy link
Contributor Author

We were using an internal object that is a cache. When it's empty it is falsey. Looking forward to the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants