So far, you have learned about Python's coroutines and a bit about how a cooperative coroutine scheduler works. Now, let's try our hand at writing some asynchronous code using Python coroutines and asyncio. We start this by creating a coroutine.
Using the asyncio event loop and coroutine scheduler
Creating a coroutine
It's easy to create a coroutine—all we have to do is use the async keyword on a function and use await anytime we want to call other coroutines, as shown in following code example:
Once we have a coroutine though, we can't just call it to get the ball rolling. If we try to call it, it immediately returns a coroutine object, as shown in the following code example—that's...