avoid concurrent key removal error

This commit is contained in:
j 2016-02-23 20:51:26 +05:30
parent b50821ba85
commit e531419364

View file

@ -10,8 +10,8 @@ class Cache(dict):
now = time.time() now = time.time()
for k, value in list(self._added.items()): for k, value in list(self._added.items()):
if value < now: if value < now:
del self._added[k] self._added.pop(k, None)
del self[k] self.pop(k, None)
return dict.get(self, key) return dict.get(self, key)
def set(self, key, value, ttl=None): def set(self, key, value, ttl=None):