Introduction to AsyncIO

AsyncIO is the official asynchronous framework for Python. As explained in the previous section, this does not mean that it is the only one available. Twisted and Gevent are two other asynchronous frameworks that are very famous. However, since its release in Python 3.4, AsyncIO has become very popular rather quickly. There is no doubt that one reason for this success comes from the philosophy of Python: There should be only one obvious way to do something. Since AsyncIO is part of the standard library, it is the de facto  way to do asynchronous programming in Python. Another reason is probably that it was released with the correct timing, when developers regained interest in asynchronous programming.

AsyncIO relies on three entities:

  • Futures: They represent values that will be available later
  • Coroutines: They allow you to execute asynchronous actions
  • Event loops: They schedule the execution of the active tasks

These three entities are the classical ones in modern asynchronous programming. Let's look at each of them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.131