Skip to content

📝 Use FastAPI lifespan instead of startup event#1687

Closed
Michele0303 wants to merge 8 commits into
fastapi:mainfrom
Michele0303:docs-fastapi-lifespan-v2
Closed

📝 Use FastAPI lifespan instead of startup event#1687
Michele0303 wants to merge 8 commits into
fastapi:mainfrom
Michele0303:docs-fastapi-lifespan-v2

Conversation

@Michele0303
Copy link
Copy Markdown

This updates the FastAPI tutorial examples to use the modern
FastAPI lifespan API instead of the deprecated startup event.

The on_startup() function is intentionally kept as a plain helper
and reused by the lifespan context manager, so that existing tutorial
tests can continue to call it directly without relying on the ASGI
lifecycle.

No behavioral changes are introduced, and all tests pass.

Replace deprecated FastAPI startup events in tutorial examples
with lifespan context managers, keeping on_startup() as a helper
for tests and documentation consistency.
@github-actions github-actions Bot added the docs Improvements or additions to documentation label Dec 23, 2025
@rasifabdulrazak

This comment was marked as spam.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has a merge conflict that needs to be resolved.

@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Dec 26, 2025
@github-actions github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Dec 26, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has a merge conflict that needs to be resolved.

@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 20, 2026
@tiangolo
Copy link
Copy Markdown
Member

Thanks for the interest and work on this! ☕

I want to implement a big refactor and some features in how to handle these things, I'm not fully happy with the existing interface.

I'll do that first, and then update the docs to reflect the recommended way to do things. I don't want to update the docs yet and suggest doing something that later I will suggest doing in a different way.

So for now, I will close this one. Thank you! 🍰

@tiangolo tiangolo closed this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically generated when a PR has a merge conflict docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants