Summary

This chapter described how to deal with two issues that can happen when writing an asynchronous application: dealing with CPU-intensive tasks and dealing with blocking tasks. Solutions to both problems can be handled via schedulers and two operators: subscribe_on and observe_on. Schedulers are objects that allow us to control on which execution context the ReactiveX operators will run. A chain of operators can use as many different execution contexts as needed.

Using schedulers allows us to keep a synchronous-like code style. With their API, it is possible to execute each operator of a chain on different threads. ReactiveX and RxPY provide a very developer-friendly syntax that makes multithreading easier to use than with most other libraries and frameworks.

The three schedulers that have been detailed in the second part of this chapter are the only ones that should be needed when writing an AsyncIO application. The AsyncIO scheduler is without any doubt the most used one since it has to be provided to virtually all factory operators of an AsyncIO application. There are however some more schedulers available. Most of them deal with the event loops of other frameworks such as Twisted, Gevent, and Tornado.

The next chapter starts a series covering the implementation of a realistic application: an audio transcoding server. Going step by step in its implementation, you will see how to implement a functional and reactive asynchronous application, but also how to deal with the typical issues of asynchronous programming.

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

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