October 2018
Intermediate to advanced
420 pages
10h 26m
English
Spawning a new thread each time an item is received is an anti-pattern in most cases. Spawning a thread and deleting it is a costly operation. So doing this for each item of an observable implies a performance hit. ThreadPoolScheduler allows us to execute each item operation on a dedicated thread, but instead of spawning a thread for each item, a pool of threads is used and recycled. These threads are created once and recycled without being deleted. This allows us to use a small number of threads without creating and deleting many of them. The prototype for this operator is the following one:
ThreadPoolScheduler.__init__(self, max_workers=None)
The max_workers parameter allows us to configure how many workers will ...
Read now
Unlock full access