refactor: Pydantic webhook payload models, lifespan task cancellation, dict/Pydantic compat helpers
This commit is contained in:
@@ -55,19 +55,26 @@ class LangMiddleware(BaseHTTPMiddleware):
|
||||
async def lifespan(app: FastAPI):
|
||||
await init_db()
|
||||
log.info("%s started on %s:%s", APP_NAME, config.host, config.port)
|
||||
# Start background lock cleanup tasks
|
||||
asyncio.create_task(_start_lock_cleanup())
|
||||
tasks = [
|
||||
asyncio.create_task(_cleanup_url_locks()),
|
||||
asyncio.create_task(_cleanup_llm_locks()),
|
||||
]
|
||||
yield
|
||||
for t in tasks:
|
||||
t.cancel()
|
||||
log.info("%s shutting down", APP_NAME)
|
||||
|
||||
|
||||
async def _start_lock_cleanup():
|
||||
"""Start background tasks for cleanup of unused locks."""
|
||||
from guarddog_nexus.core.harvester import _cleanup_url_locks
|
||||
from guarddog_nexus.routes.web import _cleanup_llm_locks
|
||||
async def _cleanup_url_locks():
|
||||
from guarddog_nexus.core.harvester import _cleanup_url_locks as _fn
|
||||
|
||||
asyncio.create_task(_cleanup_url_locks())
|
||||
asyncio.create_task(_cleanup_llm_locks())
|
||||
await _fn()
|
||||
|
||||
|
||||
async def _cleanup_llm_locks():
|
||||
from guarddog_nexus.routes.web import _cleanup_llm_locks as _fn
|
||||
|
||||
await _fn()
|
||||
|
||||
|
||||
class RequestLoggingMiddleware(BaseHTTPMiddleware):
|
||||
|
||||
Reference in New Issue
Block a user