Skip to content

Commit ac04139

Browse files
committed
minor patch
1 parent 9697e80 commit ac04139

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,4 @@
417417
DEFAULT_COOKIE_DELIMITER = ';'
418418

419419
# Skip unforced HashDB flush requests below the threshold number of cached items
420-
HASHDB_FLUSH_THRESHOLD = 10
420+
HASHDB_FLUSH_THRESHOLD = 32

lib/utils/hashdb.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,22 @@ def flush(self, forced=False):
9090
self._write_cache.clear()
9191
self._cache_lock.release()
9292

93-
self.beginTransaction()
94-
for hash_, value in items:
95-
while True:
96-
try:
93+
try:
94+
self.beginTransaction()
95+
for hash_, value in items:
96+
while True:
9797
try:
98-
self.cursor.execute("INSERT INTO storage VALUES (?, ?)", (hash_, value,))
99-
except sqlite3.IntegrityError:
100-
self.cursor.execute("UPDATE storage SET value=? WHERE id=?", (value, hash_,))
101-
except sqlite3.OperationalError, ex:
102-
if not 'locked' in ex.message:
103-
raise
104-
else:
105-
break
106-
self.endTransaction()
98+
try:
99+
self.cursor.execute("INSERT INTO storage VALUES (?, ?)", (hash_, value,))
100+
except sqlite3.IntegrityError:
101+
self.cursor.execute("UPDATE storage SET value=? WHERE id=?", (value, hash_,))
102+
except sqlite3.OperationalError, ex:
103+
if not 'locked' in ex.message:
104+
raise
105+
else:
106+
break
107+
finally:
108+
self.endTransaction()
107109

108110
def beginTransaction(self):
109111
self.cursor.execute('BEGIN TRANSACTION')

0 commit comments

Comments
 (0)