Python Asyncio, Requests, Aiohttp | Make faster API Calls

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии • 358

  • @saminyead1233
    @saminyead1233 Год назад +39

    "An event loop is when we let some stuff that takes a long time do it's thing in the background. And when it's all set, the 'event loop' will 'pick it up'." is the most helpful and intuitive definition of event loop I've heard.

    • @vnagaravi
      @vnagaravi 3 месяца назад

      I have so many questions.
      So, we have two functions running in the background, correct?
      And another main function, also known as the event loop, continuously monitors both functions for completion.
      Is it using threading to create worker threads to complete those tasks?
      And monitoring with the main thread?
      I kindly request clarification on these matters.

  • @werthersoriginal
    @werthersoriginal 3 года назад +109

    I really enjoy the fast-pace and the humor of your tutorials. Keeps me from zoning out. You've got a gift for making these tutorials both informative and enjoyable.

    • @PatrickAlphaC
      @PatrickAlphaC  3 года назад +9

      Appreciate it! I’m trying to find the right style. I get some people saying they hate it, and others love it. Guess time will tell ahah

    • @werthersoriginal
      @werthersoriginal 3 года назад +2

      @@PatrickAlphaC HA! So true. Well it is definitely different and different is refreshing! I just subscribed. Looking forward to more!

    • @alexman128
      @alexman128 2 месяца назад

      x2

  • @ubaidulkhan
    @ubaidulkhan 3 года назад +42

    Best async explanation in the burger loving world!!!

  • @ermalgashimramori
    @ermalgashimramori 2 года назад +18

    One of the greatest explanations of Async in RUclips.

  • @TheHeroIsRisingUp
    @TheHeroIsRisingUp 5 месяцев назад +2

    Wow! I hope this legend continues to provide such useful lessons for all of us.

  • @ahmedb8613
    @ahmedb8613 2 месяца назад

    I cant lie the creativity in explaining async is phenomenal.

  • @KermitDominicano
    @KermitDominicano 5 месяцев назад +1

    Fantastic video. I'm working on something for my internship that involves asyncio and aiohttp and this made it very easy to understand what is going on, you explain everything so well

  • @sleepyimsomx354
    @sleepyimsomx354 6 месяцев назад

    Usually i dont understand any of the programming video but this is by far the greatest explanation video ive ever watched

  • @venkatramachandran6345
    @venkatramachandran6345 2 года назад +3

    Incredible. Thank you so much. In the middle of a development that has 300,000 inevitable API calls. Let me check how it works. Again, Thank you

    • @PatrickAlphaC
      @PatrickAlphaC  2 года назад +1

      Good luck!

    • @venkatramachandran6345
      @venkatramachandran6345 2 года назад +2

      @@PatrickAlphaC Processed 320k API with 100 APIs at a time. Out of 320k, 91 got connection error (404). When I rerun the remaining APIs, it worked. How to avoid this connection failure? It looks like a common issue in asyncio but dont see proper fix.

  • @pouyatoutounchy1238
    @pouyatoutounchy1238 4 месяца назад

    Finally, someone who explained it in a language that I know the best FOODS!
    Thank you for the tutorial, much love from Iran 😊😊

  • @kevinlao3690
    @kevinlao3690 3 месяца назад +1

    Dude this is the best explanation for asyncio that I've seen. I am surprised why this does not have enough views

  • @anoopisaac
    @anoopisaac 2 года назад +3

    really enjoyed the part where you shuttle between two pans to check if its done and in the process explaining the purpose event loop

    • @PatrickAlphaC
      @PatrickAlphaC  2 года назад

      Glad that was helpful!
      I might make this video again...

  • @vadim921
    @vadim921 2 года назад +3

    Dude this is the most amusing programming tutorial I've seen in a while! Good stuff, you've got some acting skills

    • @PatrickAlphaC
      @PatrickAlphaC  2 года назад +1

      Glad it was fun and educational hehe

    • @vadim921
      @vadim921 2 года назад

      @@PatrickAlphaC I wish you made the whole course on that stuff

  • @davidkorn5253
    @davidkorn5253 2 года назад +18

    you have a skill for making tutorials very engaging. I didn't zone out for a sec

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 года назад +12

    6:12 You could turn any synchronous (i.e. thread-blocking call) into an async one using the to_thread() function available in asyncio with Python 3.9 and later.

  • @evanfonseka5520
    @evanfonseka5520 3 года назад +3

    Ayo this is the best clip I have ever witnessed about making api calls faster, props to u my man!!

  • @903vulture
    @903vulture 2 года назад +1

    Dude, you have an amazing way for teaching things that in another way would result boring and complex. You've won a new and loyal subscriptor from Uruguay.

  • @127.
    @127. 3 года назад +6

    Finally understood how to implement asycio.
    Very well explained.
    You not trying to get everything correct in first attempt and giving errors so viewers can understand why it gave error was something very educational in this video. Subscribed.

  • @FaizanUlHaq-mf3zt
    @FaizanUlHaq-mf3zt 9 месяцев назад +2

    didnt even zone out once, loving this....SUBSCRIBED

  • @nam4574
    @nam4574 2 года назад +7

    I really really like this tutorial!! You made it really funny and enjoyable. Never had such a fun programming tutorial on youtube :D Keep going!

  • @pavanpandya9080
    @pavanpandya9080 4 месяца назад

    One of the best tutorials on Asyncio❤

  • @bravitheja1142
    @bravitheja1142 8 месяцев назад +1

    wonder i completed 17mins tutorial without getting distracted. Great way of keeping audience on focus :)

  • @paulovinicius5833
    @paulovinicius5833 3 года назад +2

    It`s been less than 1 min of video and I already want to subscribe to his channel. Done.

  • @hypebeastuchiha9229
    @hypebeastuchiha9229 2 года назад +1

    Who says programmers aren't funny? Great Vid!

  • @rns10
    @rns10 Год назад +3

    okay you are better than chatgpt.

  • @Nikki713100
    @Nikki713100 3 года назад +3

    the best tutorial on the internet, ever

  • @asimkhan-ko6ew
    @asimkhan-ko6ew Год назад +1

    Best video on aync I have ever seen. It is just like Tom cruise movie, you have to stick till end, twist may come any moment. Who knows😂

  • @AD-cw1ny
    @AD-cw1ny 2 года назад +2

    This is the best coding tutorial ever! Before finding it i was wondering what half of these things are. Now it's all clear, just like that! Thanks!

  • @malakggh
    @malakggh 2 года назад +1

    I had to stop the video, to like and comment on this amazing explanation.

  • @idlenoodle2385
    @idlenoodle2385 3 года назад +1

    I didnt come here looking for an amazing channel. but here we are

  • @yerielkim327
    @yerielkim327 2 года назад +1

    Best teacher i've ever seen. Really impressive

  • @padraic1983
    @padraic1983 2 года назад +2

    That was an AWESOME tutorial mate. Subscribed!

  • @nonesubham
    @nonesubham Год назад +1

    literally i don't feel like i am learning ASYNC, just feel like watching any comedy show..

    • @PatrickAlphaC
      @PatrickAlphaC  Год назад

      hmm... thanks for the feedback

    • @nonesubham
      @nonesubham Год назад +1

      @@PatrickAlphaC you really make asyncio easy for me thanks

    • @PatrickAlphaC
      @PatrickAlphaC  Год назад

      @@nonesubham oh ahahha

  • @andyhawaii2819
    @andyhawaii2819 2 года назад

    As a c++ guy, I can seriously appreciate this

  • @carterreynolds5649
    @carterreynolds5649 2 года назад +1

    i was having a hell of a time understanding async coding and this video really helped. Thank you! Take my sub :)

  • @RenormalizedAdvait
    @RenormalizedAdvait 2 года назад +1

    Wow! This is revolutionary technique in teaching how to code, to be honest it is better than the best tutorials here. Keep it up.

  • @kapilsonyt
    @kapilsonyt 2 года назад

    One of the best asyncio tutorial!!
    Thanks much Patrick!

  • @mattmaximo8716
    @mattmaximo8716 2 года назад +1

    this is the best tutorial i've watched on youtube. Surprisingly enjoyable for my pea brain

  • @vickysharma9227
    @vickysharma9227 2 года назад +1

    Hey Man, Thanks for the video.
    using Tasks is a super duper and important way

  • @luxeave
    @luxeave 3 года назад +4

    this kind of guide, is life-altering. just amazing, man.

  • @vickysharma9227
    @vickysharma9227 2 года назад

    For a tricker topic Very Clearly Explained.
    Thanks brother once again.

  • @h8handles
    @h8handles 3 года назад +1

    Dude please more more more where have you been my whole coding life.

  • @billjellesma1371
    @billjellesma1371 2 года назад

    Very informative. The cooking analogy was gold!

  • @kareemmahlees3597
    @kareemmahlees3597 2 года назад +1

    I watched many videos and read the docs but understandid the best from you

  • @peterwoo2718
    @peterwoo2718 9 месяцев назад +1

    the video really cool and fun. and the code examples are really helpful. Thank you!

  • @EekaMau5
    @EekaMau5 2 года назад +1

    i'm so glad I found you.. Awesomeness !!

  • @jeffreylim5920
    @jeffreylim5920 2 года назад +4

    Two things to remember when to use await.
    1. You have to await to register the task to the event loop.
    2. You have to await the coroutine to return the 'real response'.

    • @jeffreylim5920
      @jeffreylim5920 2 года назад +1

      The first job takes significant time, and this is why 11:27 method only diminished 4 seconds. (13s -> 9s)
      So when we do registering job all at once, it saves time and we could enjoy enormous time gain. (13s->1s)

    • @carterreynolds5649
      @carterreynolds5649 2 года назад

      @@jeffreylim5920 yea that's what he said lol...

    • @zmaktr
      @zmaktr Год назад

      Yes we need await before get_task(session)

  • @eugenmalatov5470
    @eugenmalatov5470 7 месяцев назад +1

    Really amazing, so well explained and funny

  • @Kaustubhingale952
    @Kaustubhingale952 Год назад +1

    This is greatest. I bow in front of you Sir!

  • @Networkprofessor
    @Networkprofessor Год назад +1

    This video makes me hungry and smarter at the same time.

  • @safeer786ful
    @safeer786ful 3 года назад +3

    Your channel is going to blow up. Amazing explanation, keep up the good work

    • @PatrickAlphaC
      @PatrickAlphaC  3 года назад +1

      “Blow up” I hope you meant ;)

    • @safeer786ful
      @safeer786ful 3 года назад +1

      @@PatrickAlphaC ofcourse! ☺

  • @froggyana
    @froggyana 3 месяца назад

    Best explanation ever! Thanks!

  • @i701Dev
    @i701Dev 3 года назад +4

    Oh man what a fun video. You have definitely earned a sub mate!

  • @damiyagondha7153
    @damiyagondha7153 8 месяцев назад

    Really loved this explanation!

  • @lucasvazdelima4420
    @lucasvazdelima4420 2 года назад

    I can't click enough on 'like' button. Thanks, your video was amazing!

  • @akashsoren1368
    @akashsoren1368 2 года назад

    Really Well explained and love the cooking. Subscribed. Very Fun to watch.

  • @SaishShettytgroxx
    @SaishShettytgroxx 3 года назад +6

    This is exactly what I was looking for. Thankss a ton

  • @smitjainsj
    @smitjainsj 2 года назад +1

    you have nailed it !!!!
    keep it up.

  • @sujalpadhiyar5731
    @sujalpadhiyar5731 Год назад +1

    Patrick great job. I didn't skip even a second till end. I request you to make more interactive videos on python.

  • @dipankardey1044
    @dipankardey1044 2 года назад +2

    12:19 I just ran the exact same code, it says RuntimeError: Event loop is closed. Win11,python 3.10.5

  • @Flyingnobull
    @Flyingnobull 2 года назад +5

    Great video Patrick! I wonder if you would make similar ones for threading, multi-processing and comparison of all concurrency features.

  • @redjinnee2008
    @redjinnee2008 2 года назад +1

    Great video my friend, await more_videos_please

  • @stro3277
    @stro3277 2 года назад +1

    your video solved my issue! thanks! highly appreciated

  • @Lorant1984
    @Lorant1984 2 года назад +1

    Oh Dude, I would love to see more tutorials done in this style! Super entertaining!

  • @PrakashReddyK
    @PrakashReddyK 2 года назад +1

    Dude , thank you for the video , you made this so easy for me to understand how asyncio works , before I could not even begin to understand this concept

  • @rolandandrews7518
    @rolandandrews7518 3 года назад +6

    good quality video right there. Synthetic and well explained. Good job man

    • @PatrickAlphaC
      @PatrickAlphaC  3 года назад

      Appreciate it! It’s a pretty tricky topic, so glad to hear it makes sense

  • @danyalt8221
    @danyalt8221 3 года назад +1

    The Best Video About AsyncIO I've Ever Seen! Thanks Man!

  • @nassehk
    @nassehk Год назад

    Loved the tutorial. Thanks 👍

  • @danielhidefjall5060
    @danielhidefjall5060 3 года назад +1

    I like your energy and humor

  • @ahmed-samer
    @ahmed-samer Год назад +1

    Great explanation, thank you!
    It would be good too if you mention your learning process to grasp different topics

    • @PatrickAlphaC
      @PatrickAlphaC  Год назад

      This is a HUGE part of it
      ruclips.net/video/IS5dAkFSo_Y/видео.html

  • @kajairokajairo2271
    @kajairokajairo2271 5 месяцев назад

    Great explanation! How will you deal with failed requests in the loop if you wanted to retry them?

    • @PatrickAlphaC
      @PatrickAlphaC  4 месяца назад +1

      @@kajairokajairo2271 you’d have to be clever about catching them, adding them to a new retry array, and trying again

    • @kajairokajairo2271
      @kajairokajairo2271 4 месяца назад

      @@PatrickAlphaC Thanks!

  • @Tntpker
    @Tntpker 3 года назад +1

    Cooking example was on point lol

  • @fuad471
    @fuad471 3 года назад +2

    amazing way of explanation with nicely chosen examples , you have a great teaching style man

    • @PatrickAlphaC
      @PatrickAlphaC  3 года назад +1

      Appreciate it! Hope it was helpful

  • @legateau5387
    @legateau5387 2 года назад +1

    Came back to this when exploring MEV and monitoring the chain for certain txs. All the code I've seen uses JS and async/await so was curious on implementing it in python.

  • @Noritoshi-r8m
    @Noritoshi-r8m 2 года назад +1

    Fantastic video dude, please share more advanced tips for Python like this!!

  • @mafirus
    @mafirus 2 года назад +2

    I'm a full-time JS web dev, and I was wondering recently what was the python approach of Promise.all()
    Thank you so much, this is great content!!!

  • @anamoly01
    @anamoly01 2 года назад +3

    Great video. would be even better if you could also show how to control number of parallel requests. Uncontrolled parallel requests will trigger dos attack protections and block your further requests.

    • @Lorant1984
      @Lorant1984 2 года назад

      No, that would be confusing, considering the topic of the tutorial. A step-by-step (keep it simple) approach is preferable.

    • @oakae326
      @oakae326 2 года назад

      having that issue now

  • @spencerphill8115
    @spencerphill8115 Год назад +1

    Great video, my only question would be is, how would you make it async if each time you made a call the url changed and there were headers involved in making the api request? Headers being content type and authentication

    • @PatrickAlphaC
      @PatrickAlphaC  Год назад +1

      You'd have to do a lot more conditionals in the code 😅

  • @ravindrakakade9859
    @ravindrakakade9859 2 года назад

    Loved the video and the enunciation!

  • @AlexRixon
    @AlexRixon 2 года назад +1

    I call you on your Ordinary Sausage "ta da!" Well played

  • @b391i
    @b391i 3 года назад +2

    Man this video is Amazing 👏 I learned all about asyncio module in Python because of you Thank you 🙏

  • @jamesyinbaare
    @jamesyinbaare Год назад

    The right terminology of *task is called spread instead of dereferencing. @ 15:36

  • @filippov_es
    @filippov_es 3 года назад +1

    It’s a kind of magic! Thank u!!!

  • @ziyiyang4550
    @ziyiyang4550 3 года назад +2

    Thank you for making this concept so straightforward!

  • @sahabtariq4039
    @sahabtariq4039 3 года назад +1

    give that man a cookie.

  • @dientu10
    @dientu10 3 года назад +2

    Well well well, to make tasks happen simultaneously, put them into an even_loop, just simple principle that i only understood after this video. The tutorial surprise my brain. Thank you!

  • @김성광-q3m
    @김성광-q3m 2 года назад +1

    I'm trying to understand how throwing tasks in an event loop by create_task in tasks list then gather the results(17:02) differs from just executing all tasks at once by gather method(16:38). It seems that gather method not only throws tasks in an event loop but also it executes and waits to be finished(?) so only difference from the two example is that whether you registered the tasks manually by adding create_task or just get them all done by gather method? Did i get it right?

  • @GurashishSingh1
    @GurashishSingh1 2 года назад +1

    This was a fun one!

  • @leoparrilha1
    @leoparrilha1 Год назад +1

    Hello, how can we add rate limit in the aiohttp requests using the gather method?

  • @dumisanimthethwa4279
    @dumisanimthethwa4279 Год назад

    Wow thank you so much Patrick

  • @raghavarahulkalavala1542
    @raghavarahulkalavala1542 Год назад +1

    great explanation

  • @EldorJ10
    @EldorJ10 2 года назад +1

    Great stuff!

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 года назад +1

    6:05 Fun fact: asyncio is written in pure Python. What was that about Python not being able to do event loops “natively”?

    • @PatrickAlphaC
      @PatrickAlphaC  2 года назад

      I meant more like javascript has the event loop as a first-class citizen.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 года назад

      @@PatrickAlphaC You mean as a built-in type? Python doesn’t have that, because it doesn’t need it.
      Remember that, unlike JavaScript, asyncio provides an API for wrapping alternative event loops, it doesn’t force you to use its default BaseEventLoop. For example, every GUI toolkit already provides its own event loop, and Python allows asyncio to work with that.

  • @45234523452345
    @45234523452345 Год назад +1

    Thanks for sharing ..

  • @jodhvirsingh8677
    @jodhvirsingh8677 Год назад

    Great video...can you kindly explain how to get the candle data of the symbols in a dataframe/s...thnx

  • @meodudu6188
    @meodudu6188 3 года назад +1

    love the papa franku cameo

  • @sheracore9190
    @sheracore9190 2 года назад +1

    It was very useful thanks dude

  • @ankitbrijwasi9902
    @ankitbrijwasi9902 3 года назад +4

    this was awesome 🔥
    thank you so much for this great video ❤️🔥😇

  • @AbhishekJain-bv6vv
    @AbhishekJain-bv6vv 3 года назад +1

    Great explanation. Wasn't able to understand the documentation, but your video made it a lot clear.

  • @onijadissanayaka6190
    @onijadissanayaka6190 2 года назад +1

    wow I leaned how to make a burger while cooking beans : )