Closed
Description
I'm getting the following ValueError occasionally when trying to set a cache item in a disk cache:
Traceback (most recent call last):
File "/Users/myuser/Source/Projects/tvapp/main.py", line 61, in <module>
tvapp_utils.check_cold_storage_shows('my-tv-cold-storage-watchlist', lists)
File "/Users/myuser/Source/Projects/tvapp/functions.py", line 502, in check_cold_storage_shows
watched_shows = self.get_watched('shows')
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/myuser/Source/Projects/tvapp/functions.py", line 682, in get_watched
data = self.tvapp.users.get_watched(self.list_user, type=type, extended='full', cache_ttl=(60*60))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/myuser/Source/Projects/tvapp/py4tvapp/users.py", line 483, in get_watched
return self.get(url, cache_ttl)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/myuser/Source/Projects/tvapp/py4tvapp/tvapp_api.py", line 42, in get
cached = self.cache.set(cache_key, response, timeout=cache_ttl)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/myuser/.local/share/virtualenvs/tvapp-pKVCxbHL/lib/python3.11/site-packages/cache3/disk.py", line 591, in set
self.try_evict(sql)
File "/Users/myuser/.local/share/virtualenvs/tvapp-pKVCxbHL/lib/python3.11/site-packages/cache3/disk.py", line 928, in try_evict
if len(self) < self.max_size:
^^^^^^^^^
ValueError: __len__() should return >= 0
It only happens occasionally and I'm not quite sure of the exact circumstances causing it but it looks like it's trying to evict an existing cache item. If it matters, I'm storing response objects from requests GET calls in the cache.
Below are any other relevant bits of info that I think may be of help. Let me know if you need anything else.
Python Version=3.11.2
Cache Init: cache = cache3.DiskCache(directory= './cache')
cache_key=tvapp_get_6788e38c2a8c2ad2af2fb1c12646faf1
cache_ttl=3600
Thanks for all your great work on this library!
Metadata
Metadata
Assignees
Labels
No labels