Hi,
Thanks..but I kinda sorta get it. Yes...periodic call back is cool
but having an issue putting the pieces together. Below is my code. I
don.t get how to link the callback and how the results propagate to
the MyPageHandler. Below I am trying to get the callback to update
the time of the call.
class Application(tornado.web.Application):
def __init__(self,store):
self.store = store
print 'periodic callback', self.store
handlers = [
(r"/", MyPageHandler),
]
tornado.web.Application.__init__(self, handlers)
class BaseHandler(tornado.web.RequestHandler):
@property
def store(self):
# Inside a handler, refer to the store with "self.store"
return self.application.store
class MyPageHandler(BaseHandler):
def get(self):
self.set_header('Content-Type', 'text/plain')
self.write('test')
print 'test', self.store
def Store():
store = time.time()
if __name__ == '__main__':
store=5
application = Application(store=store,)
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8049)
io_loop = tornado.ioloop.IOLoop.instance()
tornado.ioloop.PeriodicCallback(Store,3000,io_loop=io_loop).start()
io_loop.start()