what are the side effect of debug=True?

219 views
Skip to first unread message

L-R

unread,
Apr 8, 2013, 5:41:11 PM4/8/13
to python-...@googlegroups.com
I'm making changes to the logging of some of my applications and was looking for documentation regarding what all the effects of debug=True were? Other than the obvious reloading when a file changes, what else happens when debug is turned on/off? Is this documented somewhere?

thx

L
Message has been deleted

aliane abdelouahab

unread,
Apr 8, 2013, 6:25:09 PM4/8/13
to Tornado Web Server
look here

http://www.tornadoweb.org/en/stable/overview.html#debug-mode-and-automatic-reloading

If you pass debug=True to the Application constructor, the app will be
run in debug mode. In this mode, templates will not be cached and the
app will watch for changes to its source files and reload itself when
anything changes. This reduces the need to manually restart the server
during development. However, certain failures (such as syntax errors
at import time) can still take the server down in a way that debug
mode cannot currently recover from.

Debug mode is not compatible with HTTPServer‘s multi-process mode. You
must not give HTTPServer.start an argument greater than 1 if you are
using debug mode.

The automatic reloading feature of debug mode is available as a
standalone module in tornado.autoreload, and is optionally used by the
test runner in tornado.testing.main.

Reloading loses any Python interpreter command-line arguments (e.g. -
u) because it re-executes Python using sys.executable and sys.argv.
Additionally, modifying these variables will cause reloading to behave
incorrectly.

Laurier Rochon

unread,
Apr 8, 2013, 6:26:28 PM4/8/13
to python-...@googlegroups.com
Ah great! I thought I'd seen this before, somehow couldn't find either through google nor the tornado site.

thanks!


On Mon, Apr 8, 2013 at 6:23 PM, aliane abdelouahab <alabde...@gmail.com> wrote:
look here

http://www.tornadoweb.org/en/stable/overview.html#debug-mode-and-automatic-reloading

If you pass debug=True to the Application constructor, the app will be
run in debug mode. In this mode, templates will not be cached and the
app will watch for changes to its source files and reload itself when
anything changes. This reduces the need to manually restart the server
during development. However, certain failures (such as syntax errors
at import time) can still take the server down in a way that debug
mode cannot currently recover from.

Debug mode is not compatible with HTTPServer‘s multi-process mode. You
must not give HTTPServer.start an argument greater than 1 if you are
using debug mode.

The automatic reloading feature of debug mode is available as a
standalone module in tornado.autoreload, and is optionally used by the
test runner in tornado.testing.main.

Reloading loses any Python interpreter command-line arguments (e.g. -
u) because it re-executes Python using sys.executable and sys.argv.
Additionally, modifying these variables will cause reloading to behave
incorrectly.

On 8 avr, 22:41, L-R <laur...@human.co> wrote:
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



aliane abdelouahab

unread,
Apr 8, 2013, 6:29:48 PM4/8/13
to Tornado Web Server
you're welcome :)
i also have problems with debug:True on windows, this will not work
because it will not stop the current python process which tells
tornado that the port is being used and it will no reload. so because
am learning on windows, i always make debug:False (or delete the line
because False is the default)

On 8 avr, 23:26, Laurier Rochon <laur...@human.co> wrote:
> Ah great! I thought I'd seen this before, somehow couldn't find either
> through google nor the tornado site.
>
> thanks!
>
> On Mon, Apr 8, 2013 at 6:23 PM, aliane abdelouahab
> <alabdeloua...@gmail.com>wrote:
>
>
>
>
>
>
>
> > look here
>
> >http://www.tornadoweb.org/en/stable/overview.html#debug-mode-and-auto...

aliane abdelouahab

unread,
Apr 8, 2013, 6:36:48 PM4/8/13
to Tornado Web Server
Update: the process is reloaded, but when stopped and reloaded, it
seems that in IDE it will show that the process is stopped (Aptana
studio, scite), so when you hit 'run' it tells you that python is
already running and holding that port.

On 8 avr, 23:26, Laurier Rochon <laur...@human.co> wrote:
> Ah great! I thought I'd seen this before, somehow couldn't find either
> through google nor the tornado site.
>
> thanks!
>
> On Mon, Apr 8, 2013 at 6:23 PM, aliane abdelouahab

Ben Darnell

unread,
Apr 8, 2013, 8:59:11 PM4/8/13
to Tornado Mailing List
On Mon, Apr 8, 2013 at 6:23 PM, aliane abdelouahab <alabde...@gmail.com> wrote:
If you pass debug=True to the Application constructor, the app will be
run in debug mode. In this mode, templates will not be cached and the
app will watch for changes to its source files and reload itself when
anything changes. This reduces the need to manually restart the server
during development. However, certain failures (such as syntax errors
at import time) can still take the server down in a way that debug
mode cannot currently recover from.

Debug mode is not compatible with HTTPServer‘s multi-process mode. You
must not give HTTPServer.start an argument greater than 1 if you are
using debug mode.

The automatic reloading feature of debug mode is available as a
standalone module in tornado.autoreload, and is optionally used by the
test runner in tornado.testing.main.

Reloading loses any Python interpreter command-line arguments (e.g. -
u) because it re-executes Python using sys.executable and sys.argv.
Additionally, modifying these variables will cause reloading to behave
incorrectly.

This document is a little out of date; there is one more effect:  in debug mode an uncaught exception will cause the stack trace to be printed to the browser instead of just to the logs.

-Ben
 

On 8 avr, 22:41, L-R <laur...@human.co> wrote:

Ben Darnell

unread,
Apr 8, 2013, 9:05:22 PM4/8/13
to Tornado Mailing List
On Mon, Apr 8, 2013 at 6:36 PM, aliane abdelouahab <alabde...@gmail.com> wrote:
Update: the process is reloaded, but when stopped and reloaded, it
seems that in IDE it  will show that the process is stopped (Aptana
studio, scite), so when you hit 'run' it tells  you that python is
already running and holding that port.

Yes, on platforms where we can't use the in-place "exec" system call (which includes Windows and OSX before 10.6) the automatic reload creates a new process and causes the old one to exit.  The reloaded server is still running (unless it hit a syntax error or something), so you can go to it in your browser, but the IDE won't know that it's there (which ironically means that if you're using an actual debugger you probably want to turn off the tornado debug flag).  

-Ben

Serge S. Koval

unread,
Apr 9, 2013, 5:18:56 AM4/9/13
to python-...@googlegroups.com
Quick question - is it possible to capture stack trace when adding ioloop callback in debug mode and output it in case of exceptions?

For example, sometimes I had following problem:
1. Something is doing add_callback to the function
2. Number of arguments doesn't match
3. Unhandled exception is triggered
4. I have no idea what it was, because there's no stack trace and there's no information about the function in question

Serge.

Ben Darnell

unread,
Apr 9, 2013, 10:18:47 AM4/9/13
to Tornado Mailing List
On Tue, Apr 9, 2013 at 5:18 AM, Serge S. Koval <serge...@gmail.com> wrote:
Quick question - is it possible to capture stack trace when adding ioloop callback in debug mode and output it in case of exceptions?

This is tricky, but it might be possible with the StackContext machinery.  I don't think you can do it by just defining a new StackContext; you'd need to add something to stack_context.wrap() to optionally save the stack.

-Ben

aliane abdelouahab

unread,
Apr 9, 2013, 2:43:02 PM4/9/13
to Tornado Web Server
now i get why, thank you :)

On 9 avr, 02:05, Ben Darnell <b...@bendarnell.com> wrote:
> On Mon, Apr 8, 2013 at 6:36 PM, aliane abdelouahab
> <alabdeloua...@gmail.com>wrote:
Reply all
Reply to author
Forward
0 new messages