out_only.py 615 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
#!/usr/bin/env python3

import time

import zmq

import sn


10 11 12 13 14
class MyBox(sn.SNGeneratorBox):
    def setup(self):
        return {
                "foo": "bar",
        }
15

16 17
    def teardown(self):
        print("teardown")
18 19


20 21 22 23
    def process(self):
        serial = 0
        while True:
            data = {
24
                "foo": self.ctx.foo,
25 26 27
                "serial": serial,
                "ts": int(time.time()),
            }
28

29
            serial += 1
30

31
            yield "sentinel/dev/sn", data
32

33 34
            print("PUB", data)
            time.sleep(1)
35 36 37


if __name__ == "__main__":
38
    MyBox("out_only").run()