How to execute / debug a python web application?

I cannot find any information on debugging a python web application, in particular, to execute a web request.

Is it just not possible? if not, why?

+5
source share
3 answers

If you put

import pdb
pdb.set_trace()

in your code, the web application will crash into the pdb debugger session after execution set_trace.

Also useful

import code
code.interact(local=locals())

which brings you to the python interpreter. Pressing Ctrl-d resumes execution.

Even more useful

import IPython.Shell 
ipshell = IPython.Shell.IPShellEmbed()
ipshell(local_ns=locals())

which takes you to an IPython session (assuming you installed IPython). Here, also pressing Ctrl-d resumes execution.

+9
source

- apache mod_wsgi mod_python, pdb. , apache -X.

Gentoo ( , apache init script -k start -X):

/usr/sbin/apache2 -D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PYTHON -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf -X
+3

use Python Debbuger, import pdb; pdb.set_trace()exactly where you want to start debugging, and your terminal will stop at that line. More details here: http://plone.org/documentation/kb/using-pdb

0
source

All Articles