Skip to content

Commit ba764bc

Browse files
committed
Revert "fix: replace deprecated @app.on_event with lifespan handlers"
This reverts commit 010b798.
1 parent 010b798 commit ba764bc

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

backend-py/src/main.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import time
22
import uuid
3-
from contextlib import asynccontextmanager
43

54
import structlog
65
from fastapi import FastAPI, Request
@@ -26,27 +25,10 @@
2625
},
2726
]
2827

29-
30-
@asynccontextmanager
31-
async def lifespan(app: FastAPI):
32-
"""Lifespan context manager for startup and shutdown events."""
33-
# Startup
34-
logger.info(
35-
"Application startup complete",
36-
service="backend-py",
37-
version="0.1.0",
38-
api_prefix=api_prefix_v1,
39-
)
40-
yield
41-
# Shutdown
42-
logger.info("Application shutdown initiated")
43-
44-
4528
app = FastAPI(
4629
title=OpenAPIInfo["title"],
4730
version=OpenAPIInfo["version"],
4831
openapi_tags=tags_metadata,
49-
lifespan=lifespan,
5032
)
5133

5234

@@ -165,3 +147,20 @@ async def root():
165147

166148

167149
app.include_router(user_router, prefix=api_prefix_v1 + "/user", tags=["User CRUD"])
150+
151+
152+
# Startup event
153+
@app.on_event("startup")
154+
async def startup_event():
155+
logger.info(
156+
"Application startup complete",
157+
service="backend-py",
158+
version="0.1.0",
159+
api_prefix=api_prefix_v1,
160+
)
161+
162+
163+
# Shutdown event
164+
@app.on_event("shutdown")
165+
async def shutdown_event():
166+
logger.info("Application shutdown initiated")

0 commit comments

Comments
 (0)