chore: migrate @app.on_event('startup') to FastAPI lifespan handler #70

Closed
opened 2026-04-05 20:59:39 -07:00 by pyr0ball · 1 comment
Owner

Summary

dev_api.py uses the deprecated @app.on_event('startup') pattern (line ~142), which triggers a deprecation warning in recent FastAPI versions.

Change

Migrate to the lifespan context manager pattern:

from contextlib import asynccontextmanager

@asynccontextmanager
async def lifespan(app: FastAPI):
    # startup logic here
    yield
    # shutdown logic here (if any)

app = FastAPI(title="Peregrine Dev API", lifespan=lifespan)

Priority

Low — deprecation warning only, no functional impact yet.

## Summary `dev_api.py` uses the deprecated `@app.on_event('startup')` pattern (line ~142), which triggers a deprecation warning in recent FastAPI versions. ## Change Migrate to the `lifespan` context manager pattern: ```python from contextlib import asynccontextmanager @asynccontextmanager async def lifespan(app: FastAPI): # startup logic here yield # shutdown logic here (if any) app = FastAPI(title="Peregrine Dev API", lifespan=lifespan) ``` ## Priority Low — deprecation warning only, no functional impact yet.
Author
Owner

Migrated in c0649c7. @app.on_event("startup") replaced with @asynccontextmanager async def lifespan(app). Startup logic unchanged; no shutdown handler needed. All 671 tests pass.

Migrated in c0649c7. `@app.on_event("startup")` replaced with `@asynccontextmanager async def lifespan(app)`. Startup logic unchanged; no shutdown handler needed. All 671 tests pass.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/peregrine#70
No description provided.