I've seen a lot of asyn videos and this one is one of the best ones, example sync code really shows you both theoretically and experimentally how important async is. Thanx a lot
Hey Anthony, Have you considered showing off the httpx library for this use case? It (mostly) has a requests based API, and I personally found the transition from requests -> httpx with async code much easier! Also, don't forget about having requests / httpx build the querystring for you instead of using f strings ;) Thanks and loved the video!
What if you have another function that takes those view counts and does some processing on that. And you want to return results after processing every view count as they get appended in the view counts list
Hi, If the video_id endpoint had multiple pages insted of just one as shown in the video ... How can we get all the pages of one endpoint using asyncio
What if I want it to have the same order as sync code.For example if i want to have all the videos analized from oldest to newest and then display it on a website ...Can i use async code then?
Sadly this wont work with many APIs since there s a limitation to frequest requests. How do i process a big list of items in batches (say 20 in one spin)?
It's a lot easier to understand than multithreading, I think. And async is great for when you need to do a lot of things that require you to wait like sending an API request.
@@prettyprinted what if you were using a request session to login to a large list of different URL's. Do you think async would be faster/better or multithreading? From what I understand, async would probably be faster because threads are limit to hardware (20 max for example) whilst async could send much more than 20 requests and await their response. For example, if 20 threads visited 20 slow sites they would all wait for each site to respond, however, with async it will load all of the URL's in the list while waiting for their response. is that correct?
Finally someone said it. The code show above is basically synchronous execution vs parallel execution. The MEAT of asyncio was not shows. You could have achieved same, of even less than 3 seconds time with threading or multiprocessing libs python provides. I have seen tons, I mean it, I have seen tons of videos and read blogs, and no one really says where asycn would work faster sync code. If you were to process one task at a time, like you did in sync for loop, you aiohttp calls would be slight slower than request.get. The async model comes into picture where you want to increase server efficiency.
Bro , I was collecting data from *API* and stored in an *array* Using *Flask* I send the *array* via render_template('index.html',data=*array*) It works fine in Local Host prints the all data in array After I deployed into HEROKU the array was empty please help me bro ❤
Hi Anthony. Happy New Year! Thanks for this video. One question...where are you getting the value for ‘key’ variable on line 68 of your refactored code?
I have to pay your attention, that you can be banned by a webserver for sending a lot of requests in short period of time. It can be treated as a DDoS attack.
Thanks man! Question - how useful is async with typical http + db requests for different endpoints? I have a FastAPI GraphQL (Graphene) backend built with serverless aws lambda and SQLAlchemy built out and working well - but I'm not really making use of async as I'm not sure how to tell which requests would benefit from it. Thanks!
Now that's the kind of programming content I was looking for, real examples not examples with threaded print jobs
I've seen a lot of asyn videos and this one is one of the best ones, example sync code really shows you both theoretically and experimentally how important async is. Thanx a lot
I didn't think it was possible to be aroused by code but this is definitely doing something
Well I've been looking for something like this for a long time .... And this is perfect. It might be black magic, but still perfect
Hey Anthony,
Have you considered showing off the httpx library for this use case? It (mostly) has a requests based API, and I personally found the transition from requests -> httpx with async code much easier! Also, don't forget about having requests / httpx build the querystring for you instead of using f strings ;)
Thanks and loved the video!
Awesome! I was trying to implement something similar and was breaking my head for the last 2 days. I had >1000 requests to perform. Thanks!
Glad it helped!
Happy New Year, dude. Thank you for your efforts sharing your knowledge all this year. Stay safe!
Happy new year!
I really liked your way of explaining things. you are a good teacher
What you want to do is that you want to do what you want to do.
I watched this video in 2x and now my APIs run 2x as on top of the speed enhancements I got from using what I learnt in this video.
Woah, this is just what i needed! Perfect, thanks man!
Extremely useful content.
Awesome!! Happy new Year 💕
Happy new year!!
Excellent tutorial, Thanks for sharing! 😎
What if you have another function that takes those view counts and does some processing on that. And you want to return results after processing every view count as they get appended in the view counts list
You're a legend
How can I send a cookie defined as a variable with this? I've tried everything and looked everywhere and cannot get it to send the cookies I want...
Hi, If the video_id endpoint had multiple pages insted of just one as shown in the video ... How can we get all the pages of one endpoint using asyncio
What if I want it to have the same order as sync code.For example if i want to have all the videos analized from oldest to newest and then display it on a website ...Can i use async code then?
How about doing the same with the same session.? (Rather than request AND aiohttp)
await async.gather(*tasks) when this will be executed? After performing all tasks done?
Sadly this wont work with many APIs since there s a limitation to frequest requests. How do i process a big list of items in batches (say 20 in one spin)?
Thank you for this video!
Thank for video and Happy New Year ! could you tell me is it possible to use async with proxy
Such a good video brother thanks!
How can I adjust access token in url ?? I wanna make 1k api calls that has authorization key
Hi , How to handle asyncio.timeout error
How is it different from multi threading, and which is faster for this use case?
It's a lot easier to understand than multithreading, I think. And async is great for when you need to do a lot of things that require you to wait like sending an API request.
@@prettyprinted what if you were using a request session to login to a large list of different URL's. Do you think async would be faster/better or multithreading? From what I understand, async would probably be faster because threads are limit to hardware (20 max for example) whilst async could send much more than 20 requests and await their response.
For example, if 20 threads visited 20 slow sites they would all wait for each site to respond, however, with async it will load all of the URL's in the list while waiting for their response. is that correct?
Finally someone said it. The code show above is basically synchronous execution vs parallel execution. The MEAT of asyncio was not shows. You could have achieved same, of even less than 3 seconds time with threading or multiprocessing libs python provides. I have seen tons, I mean it, I have seen tons of videos and read blogs, and no one really says where asycn would work faster sync code.
If you were to process one task at a time, like you did in sync for loop, you aiohttp calls would be slight slower than request.get.
The async model comes into picture where you want to increase server efficiency.
WOW, this is definitely something extremely useful!!!!
thank you very much sir!
Glad it was helpful!
How about post json data for fastest performance?
Where would you add request throttling code (different from time.sleep I am assuming)
Is it work with post request as well? Bcoz i need to dump json data in facebook graph api for each and every user...
Bro , I was collecting data from *API*
and stored in an *array*
Using *Flask*
I send the *array* via render_template('index.html',data=*array*)
It works fine in Local Host prints the all data in array
After I deployed into HEROKU the array was empty
please help me bro ❤
Do you have full course about fastapi?
Not yet. I hope to make one this year.
Hi Anthony. Happy New Year! Thanks for this video. One question...where are you getting the value for ‘key’ variable on line 68 of your refactored code?
I imported it and the variable exist in the global scope for the file.
@@prettyprinted Thanks. I should have noticed that.
Super, Subscribed :)
More Cherrypy sockets!
Awesome
Thanks for watching!
thank you so much !
thank you!
Please consider to post video to Lbry.
I have to pay your attention, that you can be banned by a webserver for sending a lot of requests in short period of time. It can be treated as a DDoS attack.
maybe I _like_ watching request results scroll down the terminal window while I draft the next script
Thanks man!
Question - how useful is async with typical http + db requests for different endpoints?
I have a FastAPI GraphQL (Graphene) backend built with serverless aws lambda and SQLAlchemy built out and working well - but I'm not really making use of async as I'm not sure how to tell which requests would benefit from it.
Thanks!
dont use it. dont use asyncio if you dont have thousand of concurrent requests.