ForcePilot/server/utils/lifespan.py

14 lines
270 B
Python
Raw Normal View History

from contextlib import asynccontextmanager
from fastapi import FastAPI
from server.services import tasker
@asynccontextmanager
async def lifespan(app: FastAPI):
await tasker.start()
"""FastAPI lifespan事件管理器"""
yield
await tasker.shutdown()