update
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
@@ -6,11 +8,20 @@ from app.core.config import get_settings
|
||||
from app.core.logging import configure_logging, setup_request_logging
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def _lifespan(app: FastAPI):
|
||||
# 启动算力状态轮询线程(同步派发到算力的训练任务状态/日志/指标)
|
||||
from app.modules.fine_tune.service import start_compute_sync_worker, stop_compute_sync_worker
|
||||
start_compute_sync_worker()
|
||||
yield
|
||||
stop_compute_sync_worker()
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
settings = get_settings()
|
||||
configure_logging(settings)
|
||||
|
||||
app = FastAPI(title=settings.app_name)
|
||||
app = FastAPI(title=settings.app_name, lifespan=_lifespan)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.cors_allow_origins,
|
||||
|
||||
Reference in New Issue
Block a user