Posts Tagged ‘Debugger’

AppEngine debugging tip

Saturday, August 22nd, 2009

Image representing Google App Engine as depict...
Image via CrunchBase
As i explained in my last blog post, GAE does some very weird stuff with stdout, making it very difficult to print information from arbitrary points of code. For example if you invoked the Pdb(stdout=sys.__stdout__) i couldn’t print on my screen from a POST request. I have finally found a fix for that annoyance, you hack sys.stdout:

def set_trace():
    import pdb, sys
    sys.stdout = sys.__stdout__
    sys.stdin = sys.__stdin__
    debugger = pdb.Pdb()
    debugger.set_trace(sys._getframe().f_back)

Blog Widget by LinkWithin