File: fib_tornado.py

package info (click to toggle)
python-streamz 0.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 824 kB
  • sloc: python: 6,714; makefile: 18; sh: 18
file content (15 lines) | stat: -rw-r--r-- 464 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from streamz import Stream
from tornado.ioloop import IOLoop


source = Stream(asynchronous=True)
s = source.sliding_window(2).map(sum)
L = s.sink_to_list()                    # store result in a list

s.rate_limit('500ms').sink(source.emit)         # pipe output back to input
s.rate_limit('1s').sink(lambda x: print(L))  # print state of L every second

source.emit(0)                          # seed with initial values
source.emit(1)

IOLoop.current().start()