rebuild(stage-9): deliver deterministic intelligent screening
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
@@ -10,6 +11,7 @@ from backend.database.migrations import MIGRATIONS, MigrationRunner
|
||||
from backend.http.errors import install_error_handlers
|
||||
from backend.http.request_context import install_request_context
|
||||
from backend.http.router import api_router
|
||||
from backend.jobs.screener import run_screener_scheduler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -34,7 +36,16 @@ def create_application(settings: Settings | None = None) -> FastAPI:
|
||||
},
|
||||
},
|
||||
)
|
||||
yield
|
||||
stop = asyncio.Event()
|
||||
task = None
|
||||
if runtime.environment != "test":
|
||||
task = asyncio.create_task(run_screener_scheduler(container.screener, stop))
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if task:
|
||||
stop.set()
|
||||
await task
|
||||
|
||||
application = FastAPI(
|
||||
title="小白复盘",
|
||||
|
||||
Reference in New Issue
Block a user