コード例 #1
0
ファイル: producer.py プロジェクト: zhangqrl/pytroll
"""

import time

from posttroll.message import Message
from dc.connections import DCConnectionsPush


class Messager(object):
    """Dummy messager class.
    """
    def __init__(self):
        self.count = 0

    def __call__(self):
        self.count += 1
        return Message('/test/1/2/3', 'info', "what's up doc #%d" % self.count)


if __name__ == '__main__':
    CONNECTIONS = DCConnectionsPush().start()
    MSG = Messager()
    while True:
        try:
            CONNECTIONS.send(MSG())
            time.sleep(1)
        except (KeyboardInterrupt, SystemExit):
            print "quitting ..."
            CONNECTIONS.stop()
            break