I have a tornado web server in python:
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
from tornado.ioloop import IOLoop
import tor
You are calling the function in stead of starting a timer. Do this:
threading.Timer(10, self.msg, args =('in timer',)).start()
could those examples help you
Tornado example
also this too Documentation tornado WS
Here's a minimal example using the PeriodicCallback
.
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
from tornado.ioloop import PeriodicCallback
import tornado.web
class WSHandler(tornado.websocket.WebSocketHandler):
def open(self):
self.callback = PeriodicCallback(self.send_hello, 120)
self.callback.start()
def send_hello(self):
self.write_message('hello')
def on_message(self, message):
pass
def on_close(self):
self.callback.stop()
application = tornado.web.Application([
(r'/', WSHandler),
])
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()