fix: 增加db.close(),解决抓取命令执行完不退出的问题

This commit is contained in:
ccgo 2024-02-22 00:11:41 +08:00
parent 4f5f83d3fa
commit c09f9fef68
2 changed files with 5 additions and 0 deletions

2
db.py
View File

@ -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)

View File

@ -52,6 +52,9 @@ async def main():
)
await crawler.start()
if config.SAVE_DATA_OPTION == "db":
await db.close()
if __name__ == '__main__':
try: