I’ve been doing a bit of Tornado work recently, and one of the things I really found annoying was the getting the auto reload functionality working when developing. I just couldn’t get it working, but eventually did it using the following code.
import tornado from tornado import autoreload tornado.options.parse_command_line() app = MyApp() app.listen(8888) ioloop = tornado.ioloop.IOLoop().instance() autoreload.start(ioloop) ioloop.start()
I also had debug set to True in my tornado settings. After that, the server automatically restarted when my modules changes.
I hope this helps someone else getting autoreload to work.
Advertisement
Worked flawlessly!! Thanks. I have a flask app running in the Tornado web server. Although its not running as a wsgi app, it is in a wsgi container. Surprisingly, the autoreload still works when I edit the Flask app’s code. Here is my code for the Tornado server:
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado import autoreload
from flask_tornado import app
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(49648)
ioloop = IOLoop.instance()
autoreload.start(ioloop)
ioloop.start()
Hey thanks for sharing your code!