Async Techniques and Examples in Python Transcripts
Chapter: Course conclusion and review
Lecture: Review: asyncio
0:00 Open this course with a quote about what is concurrency
0:03 and what is asynchrony in computer programming
0:05 from Wikipedia, specifically to highlight
0:08 that it's not just about threads.
0:10 It's also about multiprocessing
0:12 but it's also about things like asyncio
0:15 that's cooperative concurrency.
0:17 So remember, we have one main thread of execution
0:20 we have a bunch of different tasks
0:21 and we're going to break those tasks into little tiny slices.
0:25 Here they look kind of coarse grained
0:26 but imagine we're just way zoomed in.
0:28 And we break the task into different pieces
0:31 and we'll do a little bit of one, a little bit of other
0:33 a little bit of another, and we interleave these while
0:37 say the green task maybe is going to go talk to a database
0:39 so while it's talking to the database
0:41 we can run the first part of the pink task.
0:43 We get a response from the database to want to call
0:45 a webservice on the green.
0:46 Well let's go try a little blue, things like that.
0:48 So we're able to come along and just run all of these tasks
0:51 by interweaving them, because mostly what they're doing
0:54 is waiting on some external system, waiting on io.
0:58 So this is the heart of asyncio
1:00 and the async and await keywords in Python.