如何在App Engine中使用PDB?

时间:2014-10-27 20:10:26

标签: python google-app-engine pdb

我正在使用Google App Engine的开发版本(版本1.9.14.1225)构建基本网站,但我无法弄清楚如何进入调试器以确定我的模板变量未呈现的原因。

App Engine文档说使用:import pdb; pdb.set_trace();

https://cloud.google.com/appengine/docs/python/tools/devserver#Python_Debugging_with_PDB

但是,当我将pdb插入到我的代码中时,它抛出了这个错误:
    如果self.quitting:提高BdbQuit

如何输入pdb调试器?

ERROR    2014-10-30 14:25:16,768 webapp2.py:1552] 
 Traceback (most recent call last):
   File "/Users/Bryan/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
     rv = self.router.dispatch(request, response)
   File "/Users/Bryan/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
     rv = self.router.dispatch(request, response)
   File "/Users/Bryan/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
     return route.handler_adapter(request, response)
   File "/Users/Bryan/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
     return handler.dispatch()
   File "/Users/Bryan/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
     return method(*args, **kwargs)
   File "/Users/Bryan/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
     return method(*args, **kwargs)
   File "/Users/Bryan/work/GoogleAppEngine/dermalfillersecrets/main.py", line 94, in get
     self.response.write(template.render(template_values))
   File "/Users/Bryan/work/GoogleAppEngine/dermalfillersecrets/main.py", line 94, in get
     self.response.write(template.render(template_values))
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py", line 49, in trace_dispatch
     return self.dispatch_line(frame)
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py", line 68, in dispatch_line
     if self.quitting: raise BdbQuit

osX 10.9.5

2 个答案:

答案 0 :(得分:1)

它与PDB和Mac一起显示like there is a known issue。我愿意"明星"它增加了更多的重量并评论你仍然看到了这个问题。

看起来是因为PDB使用stdin / stdout进行i / o而MAC dev_server不能使用它们。

看起来third party tool应该有效。

这里看起来像是you can re-direct I / O,我没有测试你可以重新指导的地方,但可能会有所帮助。

还有一个工具redirect the I/O到套接字。不确定它会起作用,但我想我会把它包括在内以防万一。

答案 1 :(得分:1)

如果您使用GUI运行您的开发服务器,我不相信您将有权访问pdb。

您应该通过以下方式尝试使用app engine命令行运行服务器:

dev_appserver.py myapp

甚至可能是django-server:django-admin runserver