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 the encoder driver

There are two blocks needed to use the encoder driver:

  • Doing the initialization
  • Sending the transcoding requests

The initialization must provide the storage path present in the configuration file. This is straightforward:

encode_init = (    config    .map(lambda i: encoder.Initialize(storage_path=i.encode.storage_path)))

Then, the encoding requests must be created each time an HTTP request comes in. Here is the code for doing this:

encode_request = (    sources.httpd.route    .filter(lambda i: i.id='flac_transcode')    .flat_map(lambda i: i.request)    .map(lambda i: encoder.EncodeMp3(        id=i.context,        data=i.data,        key=i.match_info['key'])))

The HTTP requests are emitted on the route observable of the source of the httpd driver. Only ...

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