This commit is contained in:
Miroslav Stampar 2026-02-26 11:18:19 +01:00
parent 959ba63f78
commit c2f86976fb
3 changed files with 10 additions and 6 deletions

View file

@ -144,9 +144,13 @@ class HashDB(object):
if key:
hash_ = HashDB.hashKey(key)
with self._cache_lock:
self._write_cache[hash_] = self._read_cache[hash_] = getUnicode(value) if not serialize else serializeObject(value)
cache_size = len(self._write_cache)
time_since_flush = time.time() - self._last_flush_time
try:
self._write_cache[hash_] = self._read_cache[hash_] = getUnicode(value) if not serialize else serializeObject(value)
except RecursionError:
pass
finally:
cache_size = len(self._write_cache)
time_since_flush = time.time() - self._last_flush_time
if cache_size >= HASHDB_FLUSH_THRESHOLD_ITEMS or time_since_flush >= HASHDB_FLUSH_THRESHOLD_TIME:
self.flush()