Skip to content
Snippets Groups Projects
Verified Commit baf97bd1 authored by Mario Oenning's avatar Mario Oenning
Browse files

fix(test): FastAPI 0.104.1 - Fix warnings


FastAPI events are deprecated. Use "Lifespan" function instead.

Signed-off-by: default avatarmoson <moson@archlinux.org>
parent a0b2e826
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import re
import sys
import traceback
import typing
from contextlib import asynccontextmanager
from urllib.parse import quote_plus
import requests
......@@ -33,11 +34,18 @@ from aurweb.routers import APP_ROUTES
from aurweb.templates import make_context, render_template
logger = aur_logging.get_logger(__name__)
session_secret = aurweb.config.get("fastapi", "session_secret")
@asynccontextmanager
async def lifespan(app: FastAPI):
await app_startup()
yield
# Setup the FastAPI app.
app = FastAPI()
app = FastAPI(lifespan=lifespan)
session_secret = aurweb.config.get("fastapi", "session_secret")
# Instrument routes with the prometheus-fastapi-instrumentator
# library with custom collectors and expose /metrics.
......@@ -46,7 +54,6 @@ instrumentator().add(prometheus.http_requests_total())
instrumentator().instrument(app)
@app.on_event("startup")
async def app_startup():
# https://stackoverflow.com/questions/67054759/about-the-maximum-recursion-error-in-fastapi
# Test failures have been observed by internal starlette code when
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment