Implementation of the HTTP server driver

The HTTP server driver is implemented as a function. It takes an observable of responses as input and returns an observable of requests (referential drivers are upside down, so inputs are outputs and outputs are input). The base implementation is the following one:

def http_driver(sink, loop):    app = None    runner = None    def on_subscribe(observer):        app = web.Application()        sink.subscribe(            on_next=on_sink_item,            on_error=on_sink_error,            on_completed=on_sink_completed)    return AnonymousObservable(on_subscribe)

When being called, the http_driver function returns an observable, whose subscription function is on_subscribe. The http_driver function declares two variables, app and runner, which will be used in several ...

Get Hands-On Reactive Programming with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.