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 AsyncIO scheduler

Last but not least, AsyncIOScheduler allows us to schedule the emissions of an observable on an AsyncIO event loop. Obviously, when writing an application based on AsyncIO and ReactiveX, this is the most used scheduler. The prototype of this scheduler is the following one:

 AsyncIOScheduler.__init__(self, loop=None)

The optional loop parameter allows us to specify the event loop to use with the scheduler. The default value uses the current event loop. Using this scheduler is the same as the other ones:

import asyncioimport threadingloop = asyncio.get_event_loop()asyncio_scheduler = AsyncIOScheduler()numbers = Observable.from_([1,2,3,4], scheduler=asyncio_scheduler)subscription = numbers \    .map(lambda i: i*2) \ .map(lambda ...
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