Fix test failures and workload/websocket behavior
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from contextlib import asynccontextmanager
|
||||
from datetime import datetime
|
||||
from fastapi import FastAPI, Request, APIRouter
|
||||
@@ -16,11 +17,16 @@ from app.core.deprecation import DeprecationMiddleware
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Manage application lifespan events."""
|
||||
testing = os.environ.get("TESTING", "").lower() in ("true", "1", "yes")
|
||||
scheduler_disabled = os.environ.get("DISABLE_SCHEDULER", "").lower() in ("true", "1", "yes")
|
||||
start_background_jobs = not testing and not scheduler_disabled
|
||||
# Startup
|
||||
start_scheduler()
|
||||
if start_background_jobs:
|
||||
start_scheduler()
|
||||
yield
|
||||
# Shutdown
|
||||
shutdown_scheduler()
|
||||
if start_background_jobs:
|
||||
shutdown_scheduler()
|
||||
|
||||
|
||||
from app.api.auth import router as auth_router
|
||||
|
||||
Reference in New Issue
Block a user