Python 3, an Illustrated Tour Transcripts
Chapter: Asynchronous Programming
Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay, let's look at a task. A task is responsible for executing a coroutine object in an event loop,
0:06 don't directly create task instances use the ensure future function. Let's see why it says that.
0:11 So again, this task will wrap a coroutine and allow us to use it in an event loop and ensure future is a more general function.
0:19 It takes any awaitable object and is item potent so you can call it multiple times, but it does return a task for you, something that you can run.
0:27 A couple of tips here, use loop create future instead of future to create a future again because you might have an optimized future on a certain loop.
0:37 Use asyncio gather or asyncio ensure future to create tasks from coroutines. And if you want to speed up your loop or whatnot
0:44 you can use a third-party loop, uvloop is one that has a faster loop implementation that's not in the standard library.
0:50 You can also time out a list of co-routines if you want to by calling asyncio wait and passing a list of coroutines and give it a timeout
0:58 that will run for the given amount and will time out otherwise.