Tasks

A task in Python AsyncIO is a mechanism to wrap the co-routines. Every task has a result associated with it, that may be generated immediately or may be deferred depending upon the kind of task. This result is known as the Future.

In AsyncIO, a task is a subclass of the Future which wraps around a co-routine. When a co-routine has finished generating the values, the task returns and is marked as complete by the event loop and is hence removed from the task queue of the event queue.

Now, we have a fair enough idea of the terminology associated with the use of Python AsyncIO. Let's now dive into some action and write a simple program to understand how the Python AsyncIO really works.