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

The NewThread scheduler

The NewThread scheduler spawns new threads to emit items. Depending on the operator being used to control scheduling, it spawns a new thread either for each subscription or for each emitted item. Its prototype is the following one:

NewThreadScheduler.__init__(self, thread_factory=None)

The optional thread_factory argument can be provided as an alternative way to spawn threads. If no thread factory is provided, the scheduler uses the threading.Thread class to spawn new threads and configures them as daemon threads.

The NewThreadScheduler object can be used as a parameter of a factory operator, or as a parameter of the subscribe_on operator to control source observable emissions:

from rx import Observablefrom rx.concurrency ...
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