使用Tornado执行定时任务
import datetime from tornado import web,ioloop class MainHandler(web.RequestHandler): def get(self): self.write("Hello Tornado") def callbak1(): print("每隔2s执行") def callbak2(): print("每隔5s执行") if __name__ == '__main__': application = web.Application([ (r"/",MainHandler), ]) application.listen(8001) ioloop.PeriodicCallback(callbak1,2000).start() ioloop.PeriodicCallback(callbak2,5000).start() ioloop.IOLoop.instance().start()
~~~