Python Asyncio, Requests, Aiohttp | Make faster API Calls

  Рет қаралды 131,932

Patrick Collins

Patrick Collins

Күн бұрын

Пікірлер: 355
@saminyead1233
@saminyead1233 Жыл бұрын
"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 Ай бұрын
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 жыл бұрын
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!
@alexman128
@alexman128 22 күн бұрын
x2
@ubaidulkhan
@ubaidulkhan 3 жыл бұрын
Best async explanation in the burger loving world!!!
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
🙏🙏🙏
@ermalgashimramori
@ermalgashimramori 2 жыл бұрын
One of the greatest explanations of Async in KZbin.
@ahmedb8613
@ahmedb8613 14 күн бұрын
I cant lie the creativity in explaining async is phenomenal.
@KermitDominicano
@KermitDominicano 3 ай бұрын
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
@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.
@pouyatoutounchy1238
@pouyatoutounchy1238 2 ай бұрын
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 Ай бұрын
Dude this is the best explanation for asyncio that I've seen. I am surprised why this does not have enough views
@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!
@sleepyimsomx354
@sleepyimsomx354 4 ай бұрын
Usually i dont understand any of the programming video but this is by far the greatest explanation video ive ever watched
@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
@evanfonseka5520
@evanfonseka5520 3 жыл бұрын
Ayo this is the best clip I have ever witnessed about making api calls faster, props to u my man!!
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
Much obliged friend
@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.
@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...
@TheHeroIsRisingUp
@TheHeroIsRisingUp 2 ай бұрын
Wow! I hope this legend continues to provide such useful lessons for all of us.
@bravitheja1142
@bravitheja1142 6 ай бұрын
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
@903vulture
@903vulture 2 жыл бұрын
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
@asimkhan-ko6ew
@asimkhan-ko6ew Жыл бұрын
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😂
@FaizanUlHaq-mf3zt
@FaizanUlHaq-mf3zt 7 ай бұрын
didnt even zone out once, loving this....SUBSCRIBED
@PatrickAlphaC
@PatrickAlphaC 6 ай бұрын
Ty Fren :)
@paulovinicius5833
@paulovinicius5833 2 жыл бұрын
It`s been less than 1 min of video and I already want to subscribe to his channel. Done.
@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!
@hypebeastuchiha9229
@hypebeastuchiha9229 2 жыл бұрын
Who says programmers aren't funny? Great Vid!
@pavanpandya9080
@pavanpandya9080 2 ай бұрын
One of the best tutorials on Asyncio❤
@idlenoodle2385
@idlenoodle2385 3 жыл бұрын
I didnt come here looking for an amazing channel. but here we are
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
😍😍😍
@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 :)
@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⬆️⬆️⬆️..
@rns10
@rns10 Жыл бұрын
okay you are better than chatgpt.
@Networkprofessor
@Networkprofessor Жыл бұрын
This video makes me hungry and smarter at the same time.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
yes
@vickysharma9227
@vickysharma9227 2 жыл бұрын
Hey Man, Thanks for the video. using Tasks is a super duper and important way
@luxeave
@luxeave 3 жыл бұрын
this kind of guide, is life-altering. just amazing, man.
@malakggh
@malakggh Жыл бұрын
I had to stop the video, to like and comment on this amazing explanation.
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
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!!
@redjinnee2008
@redjinnee2008 2 жыл бұрын
Great video my friend, await more_videos_please
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Appropriate joke !
@eugenmalatov5470
@eugenmalatov5470 5 ай бұрын
Really amazing, so well explained and funny
@h8handles
@h8handles 3 жыл бұрын
Dude please more more more where have you been my whole coding life.
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
I'm flattered beyond reason
@jeffreylim5920
@jeffreylim5920 2 жыл бұрын
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 жыл бұрын
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)
@vickysharma9227
@vickysharma9227 2 жыл бұрын
For a tricker topic Very Clearly Explained. Thanks brother once again.
@carterreynolds5649
@carterreynolds5649 2 жыл бұрын
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⬆️⬆️⬆️..
@nonesubham
@nonesubham Жыл бұрын
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 Жыл бұрын
@@PatrickAlphaC you really make asyncio easy for me thanks
@PatrickAlphaC
@PatrickAlphaC Жыл бұрын
@@nonesubham oh ahahha
@yerielkim327
@yerielkim327 2 жыл бұрын
Best teacher i've ever seen. Really impressive
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad it was helpful!
@jamesyinbaare
@jamesyinbaare 10 ай бұрын
The right terminology of *task is called spread instead of dereferencing. @ 15:36
@padraic1983
@padraic1983 2 жыл бұрын
That was an AWESOME tutorial mate. Subscribed!
@dipankardey1044
@dipankardey1044 2 жыл бұрын
12:19 I just ran the exact same code, it says RuntimeError: Event loop is closed. Win11,python 3.10.5
@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!
@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!!!
@Nikki713100
@Nikki713100 3 жыл бұрын
the best tutorial on the internet, ever
@kareemmahlees3597
@kareemmahlees3597 2 жыл бұрын
I watched many videos and read the docs but understandid the best from you
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad to hear it :)
@andyhawaii2819
@andyhawaii2819 Жыл бұрын
As a c++ guy, I can seriously appreciate this
@peterwoo2718
@peterwoo2718 7 ай бұрын
the video really cool and fun. and the code examples are really helpful. Thank you!
@Kaustubhingale952
@Kaustubhingale952 Жыл бұрын
This is greatest. I bow in front of you Sir!
@billjellesma1371
@billjellesma1371 2 жыл бұрын
Very informative. The cooking analogy was gold!
@kapilsonyt
@kapilsonyt 2 жыл бұрын
One of the best asyncio tutorial!! Thanks much Patrick!
@damiyagondha7153
@damiyagondha7153 5 ай бұрын
Really loved this explanation!
@froggyana
@froggyana Ай бұрын
Best explanation ever! Thanks!
@akashsoren1368
@akashsoren1368 2 жыл бұрын
Really Well explained and love the cooking. Subscribed. Very Fun to watch.
@EekaMau5
@EekaMau5 Жыл бұрын
i'm so glad I found you.. Awesomeness !!
@Lorant1984
@Lorant1984 2 жыл бұрын
Oh Dude, I would love to see more tutorials done in this style! Super entertaining!
@lucasvazdelima4420
@lucasvazdelima4420 2 жыл бұрын
I can't click enough on 'like' button. Thanks, your video was amazing!
@Flyingnobull
@Flyingnobull 2 жыл бұрын
Great video Patrick! I wonder if you would make similar ones for threading, multi-processing and comparison of all concurrency features.
@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! ☺
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
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 Жыл бұрын
I meant more like javascript has the event loop as a first-class citizen.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
@@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.
@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
@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
@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
@i701Dev
@i701Dev 3 жыл бұрын
Oh man what a fun video. You have definitely earned a sub mate!
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
Thank you!
@SaishShettytgroxx
@SaishShettytgroxx 3 жыл бұрын
This is exactly what I was looking for. Thankss a ton
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
Beautiful!
@onijadissanayaka6190
@onijadissanayaka6190 2 жыл бұрын
wow I leaned how to make a burger while cooking beans : )
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
That was the real take away
@dientu10
@dientu10 3 жыл бұрын
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 3 жыл бұрын
Glad this is what helped it click!
@AR-fh2uh
@AR-fh2uh 2 жыл бұрын
I call you on your Ordinary Sausage "ta da!" Well played
@45234523452345
@45234523452345 11 ай бұрын
Thanks for sharing ..
@spencerphill8115
@spencerphill8115 10 ай бұрын
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 10 ай бұрын
You'd have to do a lot more conditionals in the code 😅
@sahabtariq4039
@sahabtariq4039 2 жыл бұрын
give that man a cookie.
@stro3277
@stro3277 2 жыл бұрын
your video solved my issue! thanks! highly appreciated
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Let's gooo!!
@Noritoshi-r8m
@Noritoshi-r8m 2 жыл бұрын
Fantastic video dude, please share more advanced tips for Python like this!!
@raghavarahulkalavala1542
@raghavarahulkalavala1542 Жыл бұрын
great explanation
@danielhidefjall5060
@danielhidefjall5060 3 жыл бұрын
I like your energy and humor
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
I like you liking it
@dumisanimthethwa4279
@dumisanimthethwa4279 Жыл бұрын
Wow thank you so much Patrick
@GurashishSingh1
@GurashishSingh1 Жыл бұрын
This was a fun one!
@김성광-q3m
@김성광-q3m 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?
@EldorJ10
@EldorJ10 2 жыл бұрын
Great stuff!
@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.
@smitjainsj
@smitjainsj 2 жыл бұрын
you have nailed it !!!! keep it up.
@h00t-h00t
@h00t-h00t Жыл бұрын
Amazing stuff ❤❤
@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
@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
@danyalt8221
@danyalt8221 2 жыл бұрын
The Best Video About AsyncIO I've Ever Seen! Thanks Man!
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad to hear it!
@PrakashReddyK
@PrakashReddyK 2 жыл бұрын
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
@dinimueterihrhurene2772
@dinimueterihrhurene2772 2 жыл бұрын
cool I m leraning python the cooking is best analogy
@kaankosti1279
@kaankosti1279 6 ай бұрын
This is prob the best utube channel i have ever seen till now. U might also have autism. I LOVE IT I LOVE ITTTTT
@PatrickAlphaC
@PatrickAlphaC 6 ай бұрын
LMAO
@geekydanish5990
@geekydanish5990 2 жыл бұрын
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 :}
@ziyiyang4550
@ziyiyang4550 2 жыл бұрын
Thank you for making this concept so straightforward!
@leoparrilha1
@leoparrilha1 Жыл бұрын
Hello, how can we add rate limit in the aiohttp requests using the gather method?
@Tntpker
@Tntpker 2 жыл бұрын
Cooking example was on point lol
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Glad you enjoyed
@filippomarletta7867
@filippomarletta7867 3 ай бұрын
thank you, this video has been really helpfull
@meodudu6188
@meodudu6188 3 жыл бұрын
love the papa franku cameo
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
Rip pink guy
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
16:41 I get the feeling it only took that time to finish the gather call, that the response collection was not included because it hit an error.
@samuelh5
@samuelh5 3 жыл бұрын
I think it's confusing to call * "dereference," if a person either knows or is about to learn C.
@PatrickAlphaC
@PatrickAlphaC 3 жыл бұрын
You're right, I think "unpacking" is the correct term here.
@gw032sysint9
@gw032sysint9 2 жыл бұрын
It was started very nicely with a real time analogy but then you just moved too fast..some analogy in continuation should be given for async, await, tasks, gather, Analogy for aiohttp also should have meaning once told under what circumstances not to choose requests library
@PatrickAlphaC
@PatrickAlphaC 2 жыл бұрын
Thanks for the feedback!
Next-Level Concurrent Programming In Python With Asyncio
19:19
ArjanCodes
Рет қаралды 176 М.
Asyncio in Python - Full Tutorial
24:59
Tech With Tim
Рет қаралды 76 М.
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 8 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,3 МЛН
The most important Python script I ever wrote
19:58
John Watson Rooney
Рет қаралды 197 М.
Python Asynchronous Programming - AsyncIO & Async/Await
25:57
Tech With Tim
Рет қаралды 426 М.
Основы Asyncio
53:25
Python Russian
Рет қаралды 20 М.
Async for loops in Python
16:36
mCoding
Рет қаралды 63 М.
Understanding Python: Asyncio
19:43
Jake Callahan
Рет қаралды 3,5 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 112 М.