From d99d106f84b825dd39c62eb81930e72b4d77ac99 Mon Sep 17 00:00:00 2001 From: timotheyca Date: Wed, 2 Feb 2022 20:43:50 +0300 Subject: [PATCH] async io2db/db2io --- ptvp35/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ptvp35/__init__.py b/ptvp35/__init__.py index 794d13b..6aad4d4 100644 --- a/ptvp35/__init__.py +++ b/ptvp35/__init__.py @@ -193,14 +193,14 @@ class Db: self.__path_recover.unlink() self.__path_backup.unlink() - async def _rebuild_file(self, db: {}): + async def _rebuild_file(self, db: dict): if self.__path_recover.exists(): await self._finish_recovery() self.__path.touch() with open(self.__path) as file: - self.io2db(file, db) + await self.__loop.run_in_executor(None, self.io2db, file, db) with open(self.__path_backup, "w") as file: - self.__initial_size = self.db2io(db, file) + self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, db, file) self.__path_recover.touch() await self._finish_recovery() @@ -239,7 +239,7 @@ class Db: await self._dump_buffer() self.__file.close() with open(self.__path_backup, "w") as file: - self.__initial_size = self.db2io(self.__mmdb, file) + self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, self.__mmdb, file) self.__path_recover.touch() await self._finish_recovery()