feat: 引入异步文件 I/O 避免阻塞事件循环,共享全局 httpx 连接池

This commit is contained in:
amtoaer
2023-11-24 18:31:51 +08:00
parent 27b2cd7739
commit 4dee129d38
4 changed files with 33 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ import uvloop
from loguru import logger
from models import init_model
from processor import process
from processor import cleanup, process
from settings import settings
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
@@ -25,4 +25,8 @@ async def entry() -> None:
if __name__ == "__main__":
asyncio.run(entry())
with asyncio.Runner() as runner:
try:
runner.run(entry())
finally:
runner.run(cleanup())