Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppEngine: Step-by-Step Debugging

While working with AppEngine locally (i.e. using dev_appserver.py), is there anyway to do a step-by-step debugging? It is a too old fashion to use logging.info() or similar functions to show the values of all the variables in the code and decide where the error is.

like image 366
Rafid Avatar asked Dec 21 '10 09:12

Rafid


1 Answers

To expand a little bit on codeape's answer's first suggestion: Because dev_appserver.py mucks about with stdin, stdout, and stderr, a little more work is needed to set a "code breakpoint". This does the trick for me:

import sys
for attr in ('stdin', 'stdout', 'stderr'):
    setattr(sys, attr, getattr(sys, '__%s__' % attr))
import pdb
pdb.set_trace()

You'll have to run dev_appserver.py from the command line rather than via the GUI App Engine Launcher. When the pdb.set_trace() line is executed, you will be dropped into the pdb debugger at that point.

like image 153
Will McCutchen Avatar answered Oct 18 '22 11:10

Will McCutchen