I just start learning Python + Tornado for my web servers. Every time I modify some code on my python scripts or templates I have to stop the in my terminal (CTRL+C) and restart it (python server.py) and I want a more effective way to do this, that after modifying code in some files the server automatically restarts.
Previously I working with NodeJS and using supervisor to do this.
Also there is a way to reload my tab in Google Chrome so I can see the changes without reloading (F5)
Currently I'm using Ubuntu 11.10 and Sublime Text 2 and using CTRL+B on sublime text, but if the server is already running generates an error because the address and port is in use. There is a fix for that without changing the port.
Thanks.
If you are looking for automatic reloading of .py files during development. In your tornado.web.Application()
put debug=True
after your handlers.
I don't think you should do this in production environment, because such implementation typically use a background thread to actively scan files for changes, which may slow down your application.
You need to turn autoreload
on:
tornado.autoreload.start()
tornado.autoreload.watch('myfile')
Complete example at https://gist.github.com/renaud/10356841
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With