]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
possibility to disable autoreload when debug is on 896/head
authorJuraj Niznan <jurajniznan@gmail.com>
Wed, 4 Sep 2013 13:36:00 +0000 (15:36 +0200)
committerJuraj Niznan <jurajniznan@gmail.com>
Mon, 23 Sep 2013 12:49:57 +0000 (14:49 +0200)
tornado/autoreload.py
tornado/process.py
tornado/tcpserver.py
tornado/web.py

index 05754299a2c87417df9044612ce431ce62bd4f63..7fc1fc359ae44b02e5df9178d378b6ebfdc041cf 100644 (file)
@@ -21,6 +21,8 @@ keyword argument ``debug=True`` to the `tornado.web.Application` constructor.
 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.
index ffd2d29d5f4753692cf5df9241056bbb07b6e058..942c5c3f62de8ed0fcbee70164184f0071069a31 100644 (file)
@@ -92,7 +92,8 @@ def fork_processes(num_processes, max_restarts=100):
     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``.
 
index 8473a21adcb25ac2ff65cc3995b327e9ed340090..c07737329c785e7876d0e0ead7a81425a365b79b 100644 (file)
@@ -180,7 +180,8 @@ class TCPServer(object):
         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)``.
         """
index 5f8d6091b7a0c855016c18ed80a1d0ada370ed07..caeb243b1d3228aff5c9cc6ea442908e72d6590d 100644 (file)
@@ -838,7 +838,7 @@ class RequestHandler(object):
             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"]):
@@ -1447,8 +1447,13 @@ class Application(object):
         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()
 
@@ -1599,9 +1604,10 @@ class Application(object):
             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()