When using FanoutCache.get if a timeout or a sqlite error occurs it only returns the provided default which is inconsistent with the documented behaviour when providing expire_time=True:
if True, return expire_time in tuple
This may lead to unexcpeted errors like "cannot unpack non-iterable NoneType object". The problem is that the expire_time parameter is only handled in ther underlaying cache and not in the except branch.
|
def get( |
|
self, |
|
key, |
|
default=None, |
|
read=False, |
|
expire_time=False, |
|
tag=False, |
|
retry=False, |
|
): |
|
"""Retrieve value from cache. If `key` is missing, return `default`. |
|
|
|
If database timeout occurs then returns `default` unless `retry` is set |
|
to `True` (default `False`). |
|
|
|
:param key: key for item |
|
:param default: return value if key is missing (default None) |
|
:param bool read: if True, return file handle to value |
|
(default False) |
|
:param float expire_time: if True, return expire_time in tuple |
|
(default False) |
|
:param tag: if True, return tag in tuple (default False) |
|
:param bool retry: retry if database timeout occurs (default False) |
|
:return: value for item if key is found else default |
|
|
|
""" |
|
index = self._hash(key) % self._count |
|
shard = self._shards[index] |
|
try: |
|
return shard.get(key, default, read, expire_time, tag, retry) |
|
except (Timeout, sqlite3.OperationalError): |
|
return default |
When using
FanoutCache.getif a timeout or a sqlite error occurs it only returns the provided default which is inconsistent with the documented behaviour when providingexpire_time=True:This may lead to unexcpeted errors like "cannot unpack non-iterable NoneType object". The problem is that the
expire_timeparameter is only handled in ther underlaying cache and not in the except branch.python-diskcache/diskcache/fanout.py
Lines 257 to 287 in ebfa37c