This will enable autoreload mode as well as checking for changes to templates
and static resources. Note that restarting is a destructive operation
and any requests in progress will be aborted when the process restarts.
+(If you want to disable autoreload while keeping debug on pass in also the
+keyword argument ``autoreload=False``).
This module can also be used as a command-line wrapper around scripts
such as unit test runners. See the `main` method for details.
between any server code.
Note that multiple processes are not compatible with the autoreload
- module (or the debug=True option to `tornado.web.Application`).
+ module (or the ``autoreload=True`` option to `tornado.web.Application`
+ which defaults to True when ``debug=True``).
When using multiple processes, no IOLoops can be created or
referenced until after the call to ``fork_processes``.
between any server code.
Note that multiple processes are not compatible with the autoreload
- module (or the ``debug=True`` option to `tornado.web.Application`).
+ module (or the ``autoreload=True`` option to `tornado.web.Application`
+ which defaults to True when ``debug=True``).
When using multiple processes, no IOLoops can be created or
referenced until after the call to ``TCPServer.start(n)``.
"""
else:
self.finish(self.get_error_html(status_code, **kwargs))
return
- if self.settings.get("debug") and "exc_info" in kwargs:
+ if self.settings.get("debug_traceback") and "exc_info" in kwargs:
# in debug mode, try to send a traceback
self.set_header('Content-Type', 'text/plain')
for line in traceback.format_exception(*kwargs["exc_info"]):
if handlers:
self.add_handlers(".*$", handlers)
+ if self.settings.get('debug'):
+ self.settings.setdefault('autoreload', True)
+ self.settings.setdefault('template_cache', False)
+ self.settings.setdefault('debug_traceback', True)
+
# Automatically reload modified modules
- if self.settings.get("debug") and not wsgi:
+ if self.settings.get('autoreload') and not wsgi:
from tornado import autoreload
autoreload.start()
if not handler:
handler = ErrorHandler(self, request, status_code=404)
- # In debug mode, re-compile templates and reload static files on every
+ # If template cache is disabled (usually in the debug mode),
+ # re-compile templates and reload static files on every
# request so you don't need to restart to see changes
- if self.settings.get("debug"):
+ if not self.settings.get("template_cache"):
with RequestHandler._template_loader_lock:
for loader in RequestHandler._template_loaders.values():
loader.reset()