File: network_wordcount.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 (21 lines) | stat: -rw-r--r-- 449 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/env python
""" a recreation of spark-streaming's network_wordcount

https://spark.apache.org/docs/2.2.0/streaming-programming-guide.html#a-quick-example
"""
import time
from streamz import Stream

# absolute port on localhost for now
s = Stream.from_tcp(9999)
s.map(bytes.split).flatten().frequencies().sink(print)

print(
    """In another terminal execute
> nc 127.0.0.1 9999
and then start typing content
"""
)

s.start()
time.sleep(600)