Skip to content

Commit

Permalink
fix: 增加db.close(),解决抓取命令执行完不退出的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ccgo committed Feb 21, 2024
1 parent 4f5f83d commit c09f9fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit c09f9fe

Please sign in to comment.