From c09f9fef6899843b99ad5c4cd519e606525a77a6 Mon Sep 17 00:00:00 2001 From: ccgo <> Date: Thu, 22 Feb 2024 00:11:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0db.close()=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8A=93=E5=8F=96=E5=91=BD=E4=BB=A4=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=AE=8C=E4=B8=8D=E9=80=80=E5=87=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.py | 2 ++ main.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/db.py b/db.py index 8ec4d5d..b1bc15e 100644 --- a/db.py +++ b/db.py @@ -18,6 +18,8 @@ async def init_db(create_db: bool = False) -> None: _create_db=create_db ) +async def close() -> None: + await Tortoise.close_connections() async def init(): await init_db(create_db=True) diff --git a/main.py b/main.py index 7c6a82b..73a1cfc 100644 --- a/main.py +++ b/main.py @@ -51,6 +51,9 @@ async def main(): crawler_type=args.type ) await crawler.start() + + if config.SAVE_DATA_OPTION == "db": + await db.close() if __name__ == '__main__':