Hi Massimo,

The following code snippet comes from the end of gluon/cache.py 's
CacheInRam.__call__():

        value = f()
        self.locker.acquire()
        self.storage[key] = (time.time(), value)
        self.storage[CacheAbstract.cache_stats_name]['misses'] += 1
        self.locker.release()
        return value

The problem is that, in case there is an exception raised during
"value = f()", the "misses" counter should better be increased by one.
Now it did not.

The fix.

    try: value = f()
    except: raise
    else: return value
    finally:
        self.locker.acquire()
        self.storage[key] = (time.time(), value)
        self.storage[CacheAbstract.cache_stats_name]['misses'] += 1
        self.locker.release()


Similar measure should be taken to CacheInDisk, I think.

Regards,
Iceberg

Reply via email to