Async Techniques and Examples in Python Transcripts
Chapter: async and await with asyncio
Lecture: Let's do some real work
0:00 So the example you saw before
0:01 this producer and consumer thing
0:03 maybe it felt like a toy example, an artificial example.
0:06 And you're like, "Well, Michael, you took this
0:08 latency of average of 15 seconds down to 0.25 seconds
0:12 made it 60 times better, but it was fake.
0:15 It wasn't a real thing
0:17 and how about we do some real work
0:19 and actually see if you get anything close to that?"
0:22 Well, we will, we definitely will.
0:24 So it is time to do some real work
0:26 and the example that I chose is web scraping.
0:29 So what we're going to do, we're going to go
0:31 do some web scraping, make a bunch of
0:33 HTTP requests against the server
0:35 download some stuff, run some BeautifulSoup web scraping
0:39 type queries against it, and get a little bit of data out
0:42 and then print that out to the console, okay?
0:45 We're going to request a bunch of pages
0:46 and this is a perfect example for asyncio
0:49 'cause while we're waiting on one server to respond
0:51 we can issue another request
0:53 and another, and another, and another, right?
0:56 Within that hundred milliseconds
0:57 or whatever the response time is
0:59 we could issue many requests to many of our servers
1:02 and really just incredibly amplify the speed
1:05 so that's what up next.