Introduction to asyncio
The asyncio library was created to make using asynchronous processing much easier and more predictable. It was meant as a replacement for the asyncore module, which has been available for a very long time (since Python 1.5 even) but was not all that usable. The asyncio library was officially introduced for Python 3.4 and has seen many improvements with each newer Python release since.
In a nutshell, the asyncio library allows you to switch to the execution of a different function whenever you need to wait for I/O operations. So instead of Python waiting for your operating system to finish reading a file for you, blocking the entire application in the process, it can do something useful in a different function in the meantime.
Backward compatibility and async/await statements
Before we continue with any examples, it is important to know how asyncio has changed within Python versions. Even though the asyncio library was only introduced in Python 3...