Skip to content

Commit dbb07bf

Browse files
committed
Update lifespan setup
1 parent 20d925f commit dbb07bf

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

code/function/fastapp/main.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
from fastapp.utils import setup_opentelemetry
77

88

9-
def get_app(lifespan) -> FastAPI:
9+
@asynccontextmanager
10+
async def lifespan(app: FastAPI) -> None:
11+
"""Gracefully start the application before the server reports readiness."""
12+
setup_opentelemetry(app=app)
13+
yield
14+
pass
15+
16+
17+
def get_app() -> FastAPI:
1018
"""Setup the Fast API server.
1119
1220
RETURNS (FastAPI): The FastAPI object to start the server.
@@ -23,12 +31,4 @@ def get_app(lifespan) -> FastAPI:
2331
return app
2432

2533

26-
@asynccontextmanager
27-
async def lifespan(app: FastAPI) -> None:
28-
"""Gracefully start the application before the server reports readiness."""
29-
setup_opentelemetry(app=app)
30-
yield
31-
pass
32-
33-
34-
app = get_app(lifespan=lifespan)
34+
app = get_app()

0 commit comments

Comments
 (0)