What you need to know about Startup and Shutdown Events in FastAPI and ASGI Applications
Get started in FastAPI, Starlette, and ASGI!
How do startup and shutdown events work in FastAPI, Starlette, and other ASGI applications? ASGI defines startup and shutdown events through the "lifespan" of an application, which it models as a connection between the server and the app. In this video we see the right way to do it in FastAPI, Starlette, and then understand the lifespan connection type in general, which we use to build our own lifespan handler from scratch that mimics what FastAPI does.
― mCoding with James Murphy (https://mcoding.io)
Source code: https://github.com/mCodingLLC/VideosSampleCode
ASGI Spec: https://asgi.readthedocs.io/
App class video: https://youtu.be/ai7y--6ElAE
SUPPORT ME ⭐
---------------------------------------------------
Sign up on Patreon to get your donor role and early access to videos!
https://patreon.com/mCoding
Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)
https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE
Want to donate crypto? Check out the rest of my supported donations on my website!
https://mcoding.io/donate
Top patrons and donors: Laura M, Jameson, Dragos C, Vahnekie, Neel R, Matt R, Johan A, Casey G, Mark M, Mutual Information, Pi
BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: https://discord.gg/Ye9yJtZQuN
Github: https://github.com/mCodingLLC/
Reddit: https://www.reddit.com/r/mCoding/
Facebook: https://www.facebook.com/james.mcoding
CHAPTERS
---------------------------------------------------
0:00 Intro
0:32 Startup in FastAPI
2:38 What to do at startup?
4:00 Lifespan connections in ASGI
8:10 Comparing against FastAPI
12:30 An important pro-tip
https://youtu.be/_CzaciNrHRE?si=wb-M0Pd2mhDbRPsu