Chapter 2, Asynchronous Programming in Python, explained the principles of concurrency, and its two categories:
- I/O concurrency
- CPU concurrency
An asynchronous framework is designed to deal with I/O concurrency by multiplexing all I/O requests on a single process and thread. The AsyncIO framework and ReactiveX are both tools in this category. As such, they are a perfect fit for applications that are I/O bound, such as network-based applications and tasks involving interactions with databases. However, there are situations where a full asynchronous design cannot be applied. This can occur in two cases:
- When doing CPU-intensive actions
- When using blocking APIs
Both of them break the behavior of an asynchronous system because they block the event loop for a very long time, and prevent other tasks from executing. On some asynchronous frameworks, handling...