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

Cached Decorator does not support class methods #126

Open
ktaragorn opened this issue Sep 2, 2016 · 0 comments
Open

Cached Decorator does not support class methods #126

ktaragorn opened this issue Sep 2, 2016 · 0 comments

Comments

@ktaragorn
Copy link

Cached decorator doesnt appear to support class methods. This should either be fixed somehow, or if not possible, then needs to be a loud warning in the documentation.

I just spent 1/2 - 1 hr down this rabbit hole, hope no body else has to.

This fails in a very odd way.
If a class method is used to @plugin.cached(), during the run it will appear like caching isnt working. If you restart the run, you will get the error Exception: Corrupted storage file at ...../.functions .

The file exists, and if you try to load it using storage = TimedStorage(filename, file_format, TTL) as in the file xbmcmixin.py you will get the error

(Pdb) TimedStorage(filename, file_format, TTL)
*** ValueError: File not in a supported format

Upon reading the __init__ method, I went with

(Pdb) file = open(filename,rb")
(Pdb) file.seek(0)
(Pdb) import pickle
(Pdb) pickle.load(file)
*** AttributeError: 'module' object has no attribute '<NameOfTheClassOfTheCachedMethod>'

In this case the class was just for organization so I moved this particular method out of the class and it worked just fine after that.

I understand that class instance methods may be impossible to cache between calls, but I feel (given the error, not sure) that even class level methods may not work. Either way this should be made very clear in the documentation

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

No branches or pull requests

1 participant