Skip to Content
Hands-On Reactive Programming with Python
book

Hands-On Reactive Programming with Python

by Romain Picard
October 2018
Intermediate to advanced
420 pages
10h 26m
English
Packt Publishing
Content preview from Hands-On Reactive Programming with Python

Using thread pools for CPU-bound operations

There are two possible ways to deal with CPU-bound operations:

  • Split them into multiple processes
  • Split them into multiple threads (provided that several execution engines are available on the CPU)

For now, the multithreading solution will be investigated. More details on how to solve it with multiprocessing will be provided in Chapter 10, Testing and Debugging.

As explained in Chapter 5Concurrency and Parallelism in RxPY, two operators allow us to deal with schedulers and execution contexts: observe_on and subscribe_on. In the case of this application, ThreadPoolScheduler can be used. Since the encoding requests use a lot of CPU, and they can run in parallel, a thread pool can be used to execute ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Programming with Design Patterns

Python Programming with Design Patterns

James W. Cooper

Publisher Resources

ISBN: 9781789138726Supplemental Content