如何将PDB与App Engine一起使用?

2024-05-19 09:47:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用googleappengine的dev版本(1.9.14.1225版)构建一个基本站点,我不知道如何进入调试器来确定为什么我的模板变量没有呈现。在

appengine文档说要使用:import pdb;pdb.set_跟踪()

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

但是,当我在代码中插入pdb时,它抛出了一个错误:
如果自我放弃:提高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版


Tags: inpydefaultlibgooglelinecontentsbryan
2条回答

在PDB和Mac上看起来是like there is a known issue。我会“星”它增加更多的重量和评论,你仍然看到这个问题。在

看起来这是因为PDB使用stdin/stdout进行i/o,而MAC dev_服务器无法使用它们。在

似乎有一个third party tool应该可以工作。在

这里看起来像是you can re-directI/O,我没有mac来测试你可以重定向的地方,但可能会有帮助。在

还有一个工具可以redirect the I/O到一个套接字。不确定它是否能工作,但我想我会包括它只是以防万一。在

如果你用GUI运行你的开发服务器,我不相信你能访问pdb。在

您应该尝试使用命令行run server for app engine,方法是:

dev_appserver.py myapp

甚至可能是django服务器:django-admin runserver

相关问题 更多 >

    热门问题