Async application classes vs. functions

Ғылым және технология

To function or to class?
According to the spec, an ASGI application is an async callable, but when we use FastAPI, Starlette, or other ASGI frameworks, that callable is hidden in plain sight. In this video, we see how it's possible to use an application class instead of a literal async def function, and we go over reasons for preferring the class approach.
― mCoding with James Murphy (mcoding.io)
Source code: github.com/mCodingLLC/VideosS...
ASGI Spec: asgi.readthedocs.io/
SUPPORT ME ⭐
---------------------------------------------------
Sign up on Patreon to get your donor role and early access to videos!
/ mcoding
Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)
www.paypal.com/donate/?hosted...
Want to donate crypto? Check out the rest of my supported donations on my website!
mcoding.io/donate
Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, Neel R, Matt R, Johan A, Casey G, Mark M, Mutual Information, Pi
BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: / discord
Github: github.com/mCodingLLC/
Reddit: / mcoding
Facebook: / james.mcoding

Пікірлер: 14

  • @TheFerdi265
    @TheFerdi2653 ай бұрын

    I really love your videos! I started watching back when you mostly did short Python and C++ videos, and watched them even though I knew most of it already, mostly because of the clear way you presented things, and it allowed me to gain an even better understanding of it. Thank you! EDIT: Now, you increasingly cover topics that are a bit new to me, but you cover it so well that I immediately understand. You're a great teacher!

  • @draufunddran
    @draufunddran2 ай бұрын

    Are you by any chance writing a book about python or creating a course? I would 100% buy anything that was created by you.

  • @mCoding

    @mCoding

    2 ай бұрын

    I don't have any plans to write a book or make a course at the moment, my consulting business keeps me quite busy! But thank you for saying so, I appreciate your support, and I'll keep it in mind for the future.

  • @aashayamballi
    @aashayamballi2 ай бұрын

    thank you!

  • @bereck7735
    @bereck77353 ай бұрын

    nice video

  • @lm-gn8xr
    @lm-gn8xr3 ай бұрын

    Where is the better place to store a database connection: as a global variable or as a member variable of the application object ?

  • @doctor_py42

    @doctor_py42

    3 ай бұрын

    You mostly won't use ASGI directly, but I think you should use a connection pool (for example sqlalchemy comes with one already) and get a connection from it when you need it. Since requests would be performed concurrently you can't use single connection (most dbs, e.g. postgres don't support performing multiple operations concurrently on a single connection).

  • @yourdadsbestfriend7101
    @yourdadsbestfriend71012 ай бұрын

    Letsgoo

  • @user-uc6wo1lc7t
    @user-uc6wo1lc7t3 ай бұрын

    That was... Fast 😢 But stick to your plan if you think this is better! Though I really enjoy your godlike videos and wish it was a little bit longer😅

  • @30IYouTube
    @30IYouTube3 ай бұрын

    fIsrt!

  • @kicknotes
    @kicknotes3 ай бұрын

    Why so many ho-bots here only 12 minutes after the video went live? sigh.

  • @chriskeo392

    @chriskeo392

    3 ай бұрын

    Leave my GF alone!

  • @Landee
    @Landee3 ай бұрын

    I thought you were joking when you said "thanks for watching..." But no 🥲

Келесі