python-memoization icon indicating copy to clipboard operation
python-memoization copied to clipboard

an issue with cache make the entire function fail!

Open eyalk11 opened this issue 1 year ago • 1 comments

    def wrapper(*args, **kwargs):
        """The actual wrapper"""
        nonlocal hits, misses
        key = make_key(args, kwargs)
        value = cache.get(key, sentinel)
        if value is not sentinel and values_toolkit.is_cache_value_valid(value):
            with lock:
                hits += 1
            return values_toolkit.retrieve_result_from_cache_value(value)
        else:
            with lock:
                misses += 1
            result = user_function(*args, **kwargs)
            cache[key] = values_toolkit.make_cache_value(result, ttl)
            key_argument_map[key] = (args, kwargs)
            return result

cache.get fails on exception in hash_ function of one of the args.

Why does it cause the entire function to fail? Why there is no try..catch around it?

eyalk11 avatar Aug 30 '24 19:08 eyalk11