Menu Search

recurring_timer_tornado.py

from proton.reactor import Handler
from proton_tornado import Container


class Recurring(Handler):
    def __init__(self, period):
        self.period = period

    def on_reactor_init(self, event):
        self.container = event.container
        self.container.schedule(self.period, self)

    def on_timer_task(self, event):
        print("Tick...")
        self.container.schedule(self.period, self)


try:
    container = Container(Recurring(1.0))
    container.run()
except KeyboardInterrupt:
    container.stop()
    print()

Download this file