Async Techniques and Examples in Python Transcripts
Chapter: async and await with asyncio
Lecture: Let's do some real work
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
So the example you saw before this producer and consumer thing maybe it felt like a toy example, an artificial example.
0:07
And you're like, "Well, Michael, you took this latency of average of 15 seconds down to 0.25 seconds made it 60 times better, but it was fake.
0:16
It wasn't a real thing and how about we do some real work and actually see if you get anything close to that?" Well, we will, we definitely will.
0:25
So it is time to do some real work and the example that I chose is web scraping. So what we're going to do, we're going to go
0:32
do some web scraping, make a bunch of HTTP requests against the server download some stuff, run some BeautifulSoup web scraping
0:40
type queries against it, and get a little bit of data out and then print that out to the console, okay? We're going to request a bunch of pages
0:47
and this is a perfect example for asyncio 'cause while we're waiting on one server to respond we can issue another request
0:54
and another, and another, and another, right? Within that hundred milliseconds or whatever the response time is
1:00
we could issue many requests to many of our servers and really just incredibly amplify the speed so that's what up next.