Skip to content
Myr

rewrite external debuggers section

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 0db9525 · Browse files · 1 file+23 added−27 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−27 removed

  • other:+23 added−27 removed

1 file+23 added−27 removed

modified:docs/errorhandling.rst+23 added-27 removed
1Handling Application Errors2===========================34.. versionadded:: 0.354Applications fail, servers fail. Sooner or later you will see an exception5in production. Even if your code is 100% correct, you will still see6exceptions from time to time. Why? Because everything else involved will7fail. Here are some situations where perfectly fine code can lead to server
563 unmodified lines
571572Working with Debuggers573----------------------574577To dig deeper, possibly to trace code execution, Flask provides a debugger out578of the box (see :ref:`debug-mode`). If you would like to use another Python579debugger, note that debuggers interfere with each other. You have to set some580options in order to use your favorite debugger:575The built-in development server provides a :ref:`debug-mode` that shows576an interactive traceback in the browser when an unhandled error occurs577during a request.578582* ``debug`` - whether to enable debug mode and catch exceptions583* ``use_debugger`` - whether to use the internal Flask debugger584* ``use_reloader`` - whether to reload and fork the process if modules585 were changed579External debuggers, such as those provided by IDEs, can offer a much580more powerful and visual debugging experience. They can also be used to581step through code during a request before an error is raised, or if no582error is raised.583587``debug`` must be True (i.e., exceptions must be caught) in order for the other588two options to have any value.584When using an external debugger, the app should still be in debug mode,585but it can be useful to disable the built-in debugger and reloader,586which can interfere.587590If you're using Aptana/Eclipse for debugging you'll need to set both591``use_debugger`` and ``use_reloader`` to False.588When running from the command line:589593A possible useful pattern for configuration is to set the following in your594config.yaml (change the block as appropriate for your application, of course)::590.. code-block:: text591596 FLASK:597 DEBUG: True598 DEBUG_WITH_APTANA: True592 $ export FLASK_ENV=development593 $ flask run --no-debugger --no-reload594600Then in your application's entry-point (main.py),601you could have something like::595When running from Python:596603 if __name__ == "__main__":604 # To allow aptana to receive errors, set use_debugger=False605 app = create_app(config="config.yaml")597.. code-block:: python598607 use_debugger = app.debug and not(app.config.get('DEBUG_WITH_APTANA'))608 app.run(use_debugger=use_debugger, debug=app.debug,609 use_reloader=use_debugger, host='0.0.0.0')599 app.run(debug=True, use_debugger=False, use_reloader=False)600601Disabling these isn't required, an external debugger will continue to602work with the following caveats. If the built-in debugger is not603disabled, it will catch unhandled exceptions before the external604debugger can. If the reloader is not disabled, it could cause an605unexpected reload if code changes during debugging.