Python Asyncio, Requests, Aiohttp | Make faster API Calls

  Рет қаралды 124,751

Patrick Collins

Patrick Collins

3 жыл бұрын

#python #asyncio #aiohttp
Python, asynchronous programming, the event loop... what is all this stuff?
We learn what python is doing in the background so we can make more API Calls faster. We learn how to go from requests to aiohttp in our code, and refactor code for asynchronous programming.
✍️Medium Post: betterprogramming.pub/python-...
⌨️ Code: github.com/PatrickAlphaC/asyn...
✅✅ Donate ✅✅
I use donated funds to spend money on making fun & informational videos.
ETH Wallet address: 0x9680201d9c93d65a3603d2088d125e955c73BD65
😸😸Join the community!😸😸
Chainlink developers discord: / discord
Alpha Chain discord: / discord
Twitter: / alphachainio
Twitter (me): / patrickalphac
Medium: / patrick.collins_58673
Twitch Stream Uploads: / @patrickalphac-alt
Twitch: / patrickalphac
All thoughts and opinions are my own.

Пікірлер: 342
@saminyead1233
@saminyead1233 10 ай бұрын
"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.
@ubaidulkhan
@ubaidulkhan 3 жыл бұрын
Best async explanation in the burger loving world!!!
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
🙏🙏🙏
@werthersoriginal
@werthersoriginal 3 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@PatrickAlphaC HA! So true. Well it is definitely different and different is refreshing! I just subscribed. Looking forward to more!
@KermitDominicano
@KermitDominicano 8 күн бұрын
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
@ermalgashimramori
@ermalgashimramori Жыл бұрын
One of the greatest explanations of Async in KZbin.
@apexlex1634
@apexlex1634 2 ай бұрын
You’re the man. 13 second code down to half a second. Thank you
@kapilsonyt
@kapilsonyt 2 жыл бұрын
One of the best asyncio tutorial!! Thanks much Patrick!
@davidkorn5253
@davidkorn5253 2 жыл бұрын
you have a skill for making tutorials very engaging. I didn't zone out for a sec
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Yay :) Glad it was helpful!
@padraic1983
@padraic1983 2 жыл бұрын
That was an AWESOME tutorial mate. Subscribed!
@nam4574
@nam4574 2 жыл бұрын
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!
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Thanks for the comment!
@sleepyimsomx354
@sleepyimsomx354 Ай бұрын
Usually i dont understand any of the programming video but this is by far the greatest explanation video ive ever watched
@903vulture
@903vulture Жыл бұрын
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.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
ty fren
@Lorant1984
@Lorant1984 2 жыл бұрын
Oh Dude, I would love to see more tutorials done in this style! Super entertaining!
@evanfonseka5520
@evanfonseka5520 2 жыл бұрын
Ayo this is the best clip I have ever witnessed about making api calls faster, props to u my man!!
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Much obliged friend
@vickysharma9227
@vickysharma9227 2 жыл бұрын
For a tricker topic Very Clearly Explained. Thanks brother once again.
@billjellesma1371
@billjellesma1371 Жыл бұрын
Very informative. The cooking analogy was gold!
@bravitheja1142
@bravitheja1142 3 ай бұрын
wonder i completed 17mins tutorial without getting distracted. Great way of keeping audience on focus :)
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
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.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
hot dog
@anoopisaac
@anoopisaac Жыл бұрын
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 Жыл бұрын
Glad that was helpful! I might make this video again...
@vadim921
@vadim921 2 жыл бұрын
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 жыл бұрын
Glad it was fun and educational hehe
@vadim921
@vadim921 2 жыл бұрын
@@PatrickAlphaC I wish you made the whole course on that stuff
@Flyingnobull
@Flyingnobull Жыл бұрын
Great video Patrick! I wonder if you would make similar ones for threading, multi-processing and comparison of all concurrency features.
@127.
@127. 3 жыл бұрын
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.
@carterreynolds5649
@carterreynolds5649 Жыл бұрын
i was having a hell of a time understanding async coding and this video really helped. Thank you! Take my sub :)
@kovychchat__my_Teleqram_id
@kovychchat__my_Teleqram_id Жыл бұрын
For more enquiries, reach out⬆️⬆️⬆️..
@mattmaximo8716
@mattmaximo8716 2 жыл бұрын
this is the best tutorial i've watched on youtube. Surprisingly enjoyable for my pea brain
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad you enjoyed fren :)
@Woeden
@Woeden 2 жыл бұрын
Fantastic video dude, please share more advanced tips for Python like this!!
@legateau5387
@legateau5387 2 жыл бұрын
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.
@asimkhan-ko6ew
@asimkhan-ko6ew 10 ай бұрын
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😂
@vickysharma9227
@vickysharma9227 2 жыл бұрын
Hey Man, Thanks for the video. using Tasks is a super duper and important way
@stro3277
@stro3277 2 жыл бұрын
your video solved my issue! thanks! highly appreciated
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Let's gooo!!
@paulovinicius5833
@paulovinicius5833 2 жыл бұрын
It`s been less than 1 min of video and I already want to subscribe to his channel. Done.
@venkatramachandran6345
@venkatramachandran6345 2 жыл бұрын
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 жыл бұрын
Good luck!
@venkatramachandran6345
@venkatramachandran6345 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.
@FaizanUlHaq-mf3zt
@FaizanUlHaq-mf3zt 4 ай бұрын
didnt even zone out once, loving this....SUBSCRIBED
@PatrickAlphaC
@PatrickAlphaC 3 ай бұрын
Ty Fren :)
@lucasvazdelima4420
@lucasvazdelima4420 Жыл бұрын
I can't click enough on 'like' button. Thanks, your video was amazing!
@Nikki713100
@Nikki713100 2 жыл бұрын
the best tutorial on the internet, ever
@yerielkim327
@yerielkim327 2 жыл бұрын
Best teacher i've ever seen. Really impressive
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad it was helpful!
@EekaMau5
@EekaMau5 Жыл бұрын
i'm so glad I found you.. Awesomeness !!
@luxeave
@luxeave 2 жыл бұрын
this kind of guide, is life-altering. just amazing, man.
@BillThornton-pm4hd
@BillThornton-pm4hd 10 ай бұрын
Thank you .. this changes everything
@nassehk
@nassehk 8 ай бұрын
Loved the tutorial. Thanks 👍
@damiyagondha7153
@damiyagondha7153 2 ай бұрын
Really loved this explanation!
@RenormalizedAdvait
@RenormalizedAdvait 2 жыл бұрын
Wow! This is revolutionary technique in teaching how to code, to be honest it is better than the best tutorials here. Keep it up.
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad it’s fun fren :)
@kovychchat__my_Teleqram_id
@kovychchat__my_Teleqram_id Жыл бұрын
For more enquiries, reach out⬆️⬆️⬆️..
@smitjainsj
@smitjainsj 2 жыл бұрын
you have nailed it !!!! keep it up.
@peterwoo2718
@peterwoo2718 4 ай бұрын
the video really cool and fun. and the code examples are really helpful. Thank you!
@AD-cw1ny
@AD-cw1ny 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!
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Perfect!!
@ziyiyang4550
@ziyiyang4550 2 жыл бұрын
Thank you for making this concept so straightforward!
@filippov_es
@filippov_es 2 жыл бұрын
It’s a kind of magic! Thank u!!!
@h8handles
@h8handles 2 жыл бұрын
Dude please more more more where have you been my whole coding life.
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
I'm flattered beyond reason
@Whoosh12345
@Whoosh12345 2 жыл бұрын
Thank you! This is exactly what I needed. Great tutorial
@kareemmahlees3597
@kareemmahlees3597 2 жыл бұрын
I watched many videos and read the docs but understandid the best from you
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad to hear it :)
@Kaustubhingale952
@Kaustubhingale952 Жыл бұрын
This is greatest. I bow in front of you Sir!
@ahmed-samer
@ahmed-samer Жыл бұрын
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 kzbin.info/www/bejne/f4SYlXShe7iilbs
@PrakashReddyK
@PrakashReddyK Жыл бұрын
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
@akashsoren1368
@akashsoren1368 Жыл бұрын
Really Well explained and love the cooking. Subscribed. Very Fun to watch.
@malakggh
@malakggh Жыл бұрын
I had to stop the video, to like and comment on this amazing explanation.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
Thank you!
@dumisanimthethwa4279
@dumisanimthethwa4279 Жыл бұрын
Wow thank you so much Patrick
@ravindrakakade9859
@ravindrakakade9859 Жыл бұрын
Loved the video and the enunciation!
@sujalpadhiyar5731
@sujalpadhiyar5731 Жыл бұрын
Patrick great job. I didn't skip even a second till end. I request you to make more interactive videos on python.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
Glad you enjoyed, and I can do that!
@geekydanish5990
@geekydanish5990 Жыл бұрын
In in the version 2 of your code you have remove the print statments for printing out the each 60 symbol and print is an i/o bound job which indeed reduces the execution time but i am sure with print statment included the execution time gonna be better that the version 1 thanks awsome job :}
@filippomarletta7867
@filippomarletta7867 20 сағат бұрын
thank you, this video has been really helpfull
@galichandreyschool
@galichandreyschool 2 жыл бұрын
Very good! :) Thank you!
@SaishShettytgroxx
@SaishShettytgroxx 2 жыл бұрын
This is exactly what I was looking for. Thankss a ton
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Beautiful!
@idlenoodle2385
@idlenoodle2385 3 жыл бұрын
I didnt come here looking for an amazing channel. but here we are
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
😍😍😍
@eugenmalatov5470
@eugenmalatov5470 2 ай бұрын
Really amazing, so well explained and funny
@hypebeastuchiha9229
@hypebeastuchiha9229 2 жыл бұрын
Who says programmers aren't funny? Great Vid!
@rolandandrews7518
@rolandandrews7518 3 жыл бұрын
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
@ishikadav1708
@ishikadav1708 11 ай бұрын
hi, i really loved the tutorial! thanks so much! one question- i have created a different python file, where you use requests, and have imported that to my main file. however, the loop is in my main file. do i add 'async with aiohttp.ClientSession() as session:' in my imported file, and add async def where my loop occurs?
@user-up1xf2lq4y
@user-up1xf2lq4y 2 жыл бұрын
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?
@SpacebarWarrior
@SpacebarWarrior 2 жыл бұрын
Very clear and concise tutorial. Love it!
@Networkprofessor
@Networkprofessor Жыл бұрын
This video makes me hungry and smarter at the same time.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
yes
@danielhidefjall5060
@danielhidefjall5060 2 жыл бұрын
I like your energy and humor
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
I like you liking it
@DM_MOTO
@DM_MOTO 2 жыл бұрын
Thank you !!
@Ji8
@Ji8 Жыл бұрын
Thanks man ✨
@fuad471
@fuad471 3 жыл бұрын
amazing way of explanation with nicely chosen examples , you have a great teaching style man
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
Appreciate it! Hope it was helpful
@mafirus
@mafirus 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!!!
@rkiacnhg
@rkiacnhg 2 жыл бұрын
nice. thanks for this
@sevashpun
@sevashpun 2 жыл бұрын
Thanks! I subscribed :D😁
@anamoly01
@anamoly01 2 жыл бұрын
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 Жыл бұрын
having that issue now
@EldorJ10
@EldorJ10 2 жыл бұрын
Great stuff!
@45234523452345
@45234523452345 8 ай бұрын
Thanks for sharing ..
@jbusmoove
@jbusmoove 8 ай бұрын
Got a new subscriber. Awesome
@GurashishSingh1
@GurashishSingh1 Жыл бұрын
This was a fun one!
@dientu10
@dientu10 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!
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad this is what helped it click!
@spencerphill8115
@spencerphill8115 7 ай бұрын
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 7 ай бұрын
You'd have to do a lot more conditionals in the code 😅
@Tntpker
@Tntpker 2 жыл бұрын
Cooking example was on point lol
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad you enjoyed
@sheracore9190
@sheracore9190 2 жыл бұрын
It was very useful thanks dude
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Boom!
@yerkebulanzhaukenov138
@yerkebulanzhaukenov138 2 жыл бұрын
Thank you bro for video so useful
@leoparrilha1
@leoparrilha1 Жыл бұрын
Hello, how can we add rate limit in the aiohttp requests using the gather method?
@goodlack9093
@goodlack9093 Ай бұрын
that's actually good!
@safeer786ful
@safeer786ful 3 жыл бұрын
Your channel is going to blow up. Amazing explanation, keep up the good work
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
“Blow up” I hope you meant ;)
@safeer786ful
@safeer786ful 3 жыл бұрын
@@PatrickAlphaC ofcourse! ☺
@b391i
@b391i 2 жыл бұрын
Man this video is Amazing 👏 I learned all about asyncio module in Python because of you Thank you 🙏
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Awesome!! Glad it helped
@idunexist
@idunexist Жыл бұрын
funny yet educational!
@aspuser1081
@aspuser1081 8 күн бұрын
Next level😊🎉
@sahabtariq4039
@sahabtariq4039 2 жыл бұрын
give that man a cookie.
@agannain
@agannain Жыл бұрын
That was an AWESOME
@rafaelcastro39
@rafaelcastro39 2 жыл бұрын
Amazing!
@lapraschaos5152
@lapraschaos5152 2 жыл бұрын
so great! love from China
@TheKenyanSoftwareEngineer
@TheKenyanSoftwareEngineer 3 жыл бұрын
This is something that i really wanted..thanks man
@dgory
@dgory 2 жыл бұрын
Great video!
@talibuddeenabdulhakeem
@talibuddeenabdulhakeem 2 жыл бұрын
This was great!
@rezaeivazzadeh4800
@rezaeivazzadeh4800 2 жыл бұрын
Wonderful
Основы Asyncio
53:25
Python Russian
Рет қаралды 11 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 96 М.
I Built a Shelter House For myself and Сat🐱📦🏠
00:35
TooTool
Рет қаралды 36 МЛН
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 18 МЛН
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 2,9 МЛН
Learn Python's AsyncIO in 15 minutes
14:02
Indently
Рет қаралды 49 М.
Async for loops in Python
16:36
mCoding
Рет қаралды 57 М.
Requests vs HTTPX vs Aiohttp | Which One to Pick?
15:11
ArjanCodes
Рет қаралды 34 М.
Lynn Root - Advanced asyncio: Solving Real-world Production Problems
40:02
EuroPython Conference
Рет қаралды 14 М.
ASYNCIO НА ПРАКТИЧЕСКОМ ПРИМЕРЕ
22:44
luchanos
Рет қаралды 26 М.
Next-Level Concurrent Programming In Python With Asyncio
19:19
ArjanCodes
Рет қаралды 165 М.
Mi primera placa con dios
0:12
Eyal mewing
Рет қаралды 719 М.
WWDC 2024 - June 10 | Apple
1:43:37
Apple
Рет қаралды 10 МЛН
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 1,9 МЛН
DC Fast 🏃‍♂️ Mobile 📱 Charger
0:42
Tech Official
Рет қаралды 485 М.