From 550458b2f15a82d807ff96b4fe8865ceab37d3c8 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 16 Nov 2020 10:53:41 -0300 Subject: [PATCH] WAL_CHECKPOINT on close --- lbry/wallet/database.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/database.py b/lbry/wallet/database.py index a1c9e4516..0534f5e57 100644 --- a/lbry/wallet/database.py +++ b/lbry/wallet/database.py @@ -121,7 +121,12 @@ class AIOSQLite: if self._closing: return self._closing = True - await asyncio.get_event_loop().run_in_executor(self.writer_executor, self.writer_connection.close) + + def __checkpoint_and_close(conn: sqlite3.Connection): + conn.execute("PRAGMA WAL_CHECKPOINT(FULL);") + conn.close() + await asyncio.get_event_loop().run_in_executor( + self.writer_executor, __checkpoint_and_close, self.writer_connection) self.writer_executor.shutdown(wait=True) self.reader_executor.shutdown(wait=True) self.read_ready.clear()