Browse Source

📝 Update documentation for deprecated on_startup and on_shutdown parameters

pull/10648/head
heysaeid 1 year ago
parent
commit
9846605462
  1. 16
      fastapi/applications.py
  2. 16
      fastapi/routing.py

16
fastapi/applications.py

@ -515,6 +515,14 @@ class FastAPI(Starlette):
Read more in the [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
"""
),
deprecated(
"""
**Attention**: This parameter is deprecated.
The recommended approach for managing startup and shutdown
is by utilizing the lifespan parameter within the FastAPI app.
"""
),
] = None,
on_shutdown: Annotated[
Optional[Sequence[Callable[[], Any]]],
@ -528,6 +536,14 @@ class FastAPI(Starlette):
[FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
"""
),
deprecated(
"""
**Attention**: This parameter is deprecated.
The recommended approach for managing startup and shutdown
is by utilizing the lifespan parameter within the FastAPI app.
"""
),
] = None,
lifespan: Annotated[
Optional[Lifespan[AppType]],

16
fastapi/routing.py

@ -690,6 +690,14 @@ class APIRouter(routing.Router):
Read more in the [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
"""
),
deprecated(
"""
**Attention**: This parameter is deprecated.
The recommended approach for managing startup and shutdown
is by utilizing the lifespan parameter within the APIRouter.
"""
),
] = None,
on_shutdown: Annotated[
Optional[Sequence[Callable[[], Any]]],
@ -703,6 +711,14 @@ class APIRouter(routing.Router):
[FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/).
"""
),
deprecated(
"""
**Attention**: This parameter is deprecated.
The recommended approach for managing startup and shutdown
is by utilizing the lifespan parameter within the APIRouter.
"""
),
] = None,
# the generic to Lifespan[AppType] is the type of the top level application
# which the router cannot know statically, so we use typing.Any

Loading…
Cancel
Save