使用 Eclipse 进行 web2py 调试
我正在使用 Eclipse(带有 PyDev)来开发 web2py 应用程序。我已按照本指南进行设置。现在,我想使用 Eclipse 调试我的应用程序。但是,由于某种原因,执行在到达断点时并不(总是)停止。
我创建了两个独立的 web2py 应用程序(在两个 Eclipse 项目中)。调试似乎对其中一个有效,但对另一个无效。两个项目都引用相同的 web2py 安装。因此,与我在 Eclipse 中“运行.../调试...”的项目无关,web2py 通过浏览器提供这两个应用程序。
我创建了一个简单的测试文件 (controllers/test.py),如下所示:
def index():
print 'I should break.'
print 'After the breakpoint'
return dict(test=1)
第一个 print
语句设置了一个断点。
我已将此文件放入两个项目中(我们称它们为 A 和 B)。
我有以下观察结果:
当我从 Eclipse 启动调试时,只要我命中属于项目 A 的文件 test.py 中的断点,调试器就会停止执行,但它似乎忽略属于项目 A 的文件 test.py 中的断点项目 B。我是从(Eclipse-)项目 A 还是项目 B 启动 web2py 并不重要。行为总是相同的。属于项目 A 的文件中的断点有效,项目 B 中的断点将被忽略。
我比较了所有项目属性和运行配置属性,但找不到差异(项目名称和路径除外)。
这两个项目的执行都很顺利。例如,上面显示的测试文件的 print
语句的输出始终显示在 Eclipse 控制台中。
有人知道这里发生了什么事吗?它在项目 A 上有效但在项目 B 上无效的区别是什么?
我正在使用Python 2.7.1。
当我在 eclipse/plugins/org.python.pydev.debug/pysrc/pydevd_constants.py 中设置时
DEBUG_TRACE_LEVEL = 3
DEBUG_TRACE_BREAKPOINTS = 3
(按照注释中的要求),我得到以下控制台输出:
pydev debugger: running ('执行文件', 'C:\misc\web2py_src\web2py\web2py.py') ('参数:', "['C:\\misc\\web2py_src\\web2py\\web2py.py']") ('连接到', '127.0.0.1', ':', '49565') (“已连接。”,) ('收到命令','501\t1\t1.1') 发送 cmd: CMD_VERSION 501 1 1.1
sending cmd: CMD_THREAD_CREATE 103 2 <xml><thread name="pydevd.reader" id="-1"/></xml>
sending cmd: CMD_THREAD_CREATE 103 4 <xml><thread name="pydevd.writer" id="-1"/></xml>
('received command ', '111\t3\tC:\\misc\\workspace\\Newtoon\\controllers\\test.py\t12\t**FUNC**index\tNone')
Added breakpoint:c:\misc\workspace\newtoon\controllers\test.py - line:12 - func_name:index
('received command ', '111\t5\tC:\\misc\\workspace\\Newtoon\\controllers\\importer.py\t11\t**FUNC**index\tNone')
Added breakpoint:c:\misc\workspace\newtoon\controllers\importer.py - line:11 - func_name:index
('received command ', '111\t7\tC:\\misc\\web2py_src\\web2py\\applications\\GeorgsTestApp\\controllers\\unique_names.py\t6\t**FUNC**index\tNone')
Added breakpoint:c:\misc\web2py_src\web2py\applications\georgstestapp\controllers\unique_names.py - line:6 - func_name:index
('received command ', '111\t9\tC:\\misc\\web2py_src\\web2py\\applications\\GeorgsTestApp\\controllers\\test.py\t12\t**FUNC**index\tNone')
Added breakpoint:c:\misc\web2py_src\web2py\applications\georgstestapp\controllers\test.py - line:12 - func_name:index
('received command ', '122\t11\t;;')
Exceptions to hook : []
('received command ', '124\t13\t')
('received command ', '101\t15\t')
No handlers could be found for logger "web2py"
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.4 (2011-12-14 14:46:14) stable
Database drivers available: SQLite3, pymysql
Starting hardcron...
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
sending cmd: CMD_THREAD_CREATE 103 6 <xml><thread name="MainThread" id="pid5740_seq4" /></xml>
sending cmd: CMD_THREAD_CREATE 103 8 <xml><thread name="Thread-4" id="pid5740_seq5" /></xml>
please visit:
http://127.0.0.1:8000
starting browser...
sending cmd: CMD_THREAD_CREATE 103 10 <xml><thread name="Dummy-7" id="pid5740_seq6" /></xml>
sending cmd: CMD_THREAD_CREATE 103 12 <xml><thread name="Dummy-6" id="pid5740_seq7" /></xml>
sending cmd: CMD_THREAD_CREATE 103 14 <xml><thread name="Thread-13" id="pid5740_seq8" /></xml>
sending cmd: CMD_THREAD_CREATE 103 16 <xml><thread name="Thread-10" id="pid5740_seq9" /></xml>
sending cmd: CMD_THREAD_CREATE 103 18 <xml><thread name="Thread-11" id="pid5740_seq10" /></xml>
sending cmd: CMD_THREAD_CREATE 103 20 <xml><thread name="Port8000" id="pid5740_seq11" /></xml>
sending cmd: CMD_THREAD_CREATE 103 22 <xml><thread name="Thread-12" id="pid5740_seq12" /></xml>
sending cmd: CMD_THREAD_CREATE 103 24 <xml><thread name="Thread-8" id="pid5740_seq13" /></xml>
sending cmd: CMD_THREAD_CREATE 103 26 <xml><thread name="Thread-9" id="pid5740_seq14" /></xml>
sending cmd: CMD_THREAD_CREATE 103 28 <xml><thread name="Thread-16" id="pid5740_seq15" /></xml>
sending cmd: CMD_THREAD_CREATE 103 30 <xml><thread name="Thread-15" id="pid5740_seq16" /></xml>
sending cmd: CMD_THREAD_CREATE 103 32 <xml><thread name="Thread-18" id="pid5740_seq17" /></xml>
sending cmd: CMD_THREAD_CREATE 103 34 <xml><thread name="Thread-14" id="pid5740_seq18" /></xml>
sending cmd: CMD_THREAD_CREATE 103 36 <xml><thread name="Thread-17" id="pid5740_seq19" /></xml>
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
I should break.
After the breakpoint
sending cmd: CMD_THREAD_SUSPEND 105 38 <xml><thread id="pid5740_seq12" stop_reason="111"><frame id="97199496" name="index" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Capplications%255Cgeorgstestapp%255Ccontrollers%255Ctest.py" line="12">"</frame><frame id="95957960" name="%26lt%3Blambda%26gt%3B" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cglobals.py" line="172">"</frame><frame id="100912680" name="%26lt%3Bmodule%26gt%3B" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Capplications%255Cgeorgstestapp%255Ccontrollers%255Ctest.py" line="19">"</frame><frame id="66219576" name="restricted" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Crestricted.py" line="204">"</frame><frame id="96138760" name="run_controller_in" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Ccompileapp.py" line="537">"</frame><frame id="96513256" name="serve_controller" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cmain.py" line="202">"</frame><frame id="62835496" name="wsgibase" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cmain.py" line="493">"</frame><frame id="62834872" name="app_with_logging" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cmain.py" line="676">"</frame><frame id="96071288" name="run_app" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Crocket.py" line="1994">"</frame><frame id="66212296" name="run" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Crocket.py" line="1302">"</frame><frame id="95948632" name="__bootstrap_inner" file="c%253A%255Cpython27%255Clib%255Cthreading.py" line="530">"</frame><frame id="96053672" name="__bootstrap" file="c%253A%255Cpython27%255Clib%255Cthreading.py" line="503">"</frame></thread></xml>
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
('received command ', '106\t17\tpid5740_seq12')
('processing internal command ', '<pydevd_comm.InternalRunThread instance at 0x0000000005F82E88>')
I should break.
After the breakpoint
sending cmd: CMD_THREAD_RUN 106 40 pid5740_seq12 None
行为不会改变。应用程序 B 中的断点被忽略,而应用程序 A 中的断点有效。
I am using Eclipse (with PyDev) to delevop a web2py application. I have followed this guide to set things up. Now, I want to debug my application using Eclipse. However, for some reason, execution does not (always) stop when it reaches a breakpoint.
I have created two separate web2py apps (in two Eclipse projects). Debugging seems to work on one, but not on the other. Both projects reference the same web2py installation. Thus, independent of which project I "Run.../Debug..." in Eclipse, web2py offers both apps via the browser.
I have created a simple test file (controllers/test.py) as follows:
def index():
print 'I should break.'
print 'After the breakpoint'
return dict(test=1)
There is a breakpoint set to the first print
statement.
I have put this file in both projects (let's call them A and B).
I have the following observations:
When I launch debugging from Eclipse, the debugger stops execution whenever I hit the breakpoint in the file test.py that belongs to project A, but it seems to ignore the breakpoint in the file test.py that belongs to project B. It does not matter whether I launched web2py from (Eclipse-)project A or project B. The behavior is always the same. Breakpoints in files that belong to project A work, those in project B are ignored.
I have compared all project properties and run configuration properties and I cannot find a difference (except for the project name and path).
Execution of both projects works perfectly. E.g., the output of the print
statements of the test file shown above is always shown in the Eclipse console.
Does anybody have a clue what is going on here? What could be the difference that makes it work on project A but not on project B?
I am using Python 2.7.1.
When I set
DEBUG_TRACE_LEVEL = 3
DEBUG_TRACE_BREAKPOINTS = 3
in eclipse/plugins/org.python.pydev.debug/pysrc/pydevd_constants.py (as requested in the comments), I get the following console output:
pydev debugger: starting
('Executing file ', 'C:\misc\web2py_src\web2py\web2py.py')
('arguments:', "['C:\\misc\\web2py_src\\web2py\\web2py.py']")
('Connecting to ', '127.0.0.1', ':', '49565')
('Connected.',)
('received command ', '501\t1\t1.1')
sending cmd: CMD_VERSION 501 1 1.1
sending cmd: CMD_THREAD_CREATE 103 2 <xml><thread name="pydevd.reader" id="-1"/></xml>
sending cmd: CMD_THREAD_CREATE 103 4 <xml><thread name="pydevd.writer" id="-1"/></xml>
('received command ', '111\t3\tC:\\misc\\workspace\\Newtoon\\controllers\\test.py\t12\t**FUNC**index\tNone')
Added breakpoint:c:\misc\workspace\newtoon\controllers\test.py - line:12 - func_name:index
('received command ', '111\t5\tC:\\misc\\workspace\\Newtoon\\controllers\\importer.py\t11\t**FUNC**index\tNone')
Added breakpoint:c:\misc\workspace\newtoon\controllers\importer.py - line:11 - func_name:index
('received command ', '111\t7\tC:\\misc\\web2py_src\\web2py\\applications\\GeorgsTestApp\\controllers\\unique_names.py\t6\t**FUNC**index\tNone')
Added breakpoint:c:\misc\web2py_src\web2py\applications\georgstestapp\controllers\unique_names.py - line:6 - func_name:index
('received command ', '111\t9\tC:\\misc\\web2py_src\\web2py\\applications\\GeorgsTestApp\\controllers\\test.py\t12\t**FUNC**index\tNone')
Added breakpoint:c:\misc\web2py_src\web2py\applications\georgstestapp\controllers\test.py - line:12 - func_name:index
('received command ', '122\t11\t;;')
Exceptions to hook : []
('received command ', '124\t13\t')
('received command ', '101\t15\t')
No handlers could be found for logger "web2py"
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.4 (2011-12-14 14:46:14) stable
Database drivers available: SQLite3, pymysql
Starting hardcron...
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
sending cmd: CMD_THREAD_CREATE 103 6 <xml><thread name="MainThread" id="pid5740_seq4" /></xml>
sending cmd: CMD_THREAD_CREATE 103 8 <xml><thread name="Thread-4" id="pid5740_seq5" /></xml>
please visit:
http://127.0.0.1:8000
starting browser...
sending cmd: CMD_THREAD_CREATE 103 10 <xml><thread name="Dummy-7" id="pid5740_seq6" /></xml>
sending cmd: CMD_THREAD_CREATE 103 12 <xml><thread name="Dummy-6" id="pid5740_seq7" /></xml>
sending cmd: CMD_THREAD_CREATE 103 14 <xml><thread name="Thread-13" id="pid5740_seq8" /></xml>
sending cmd: CMD_THREAD_CREATE 103 16 <xml><thread name="Thread-10" id="pid5740_seq9" /></xml>
sending cmd: CMD_THREAD_CREATE 103 18 <xml><thread name="Thread-11" id="pid5740_seq10" /></xml>
sending cmd: CMD_THREAD_CREATE 103 20 <xml><thread name="Port8000" id="pid5740_seq11" /></xml>
sending cmd: CMD_THREAD_CREATE 103 22 <xml><thread name="Thread-12" id="pid5740_seq12" /></xml>
sending cmd: CMD_THREAD_CREATE 103 24 <xml><thread name="Thread-8" id="pid5740_seq13" /></xml>
sending cmd: CMD_THREAD_CREATE 103 26 <xml><thread name="Thread-9" id="pid5740_seq14" /></xml>
sending cmd: CMD_THREAD_CREATE 103 28 <xml><thread name="Thread-16" id="pid5740_seq15" /></xml>
sending cmd: CMD_THREAD_CREATE 103 30 <xml><thread name="Thread-15" id="pid5740_seq16" /></xml>
sending cmd: CMD_THREAD_CREATE 103 32 <xml><thread name="Thread-18" id="pid5740_seq17" /></xml>
sending cmd: CMD_THREAD_CREATE 103 34 <xml><thread name="Thread-14" id="pid5740_seq18" /></xml>
sending cmd: CMD_THREAD_CREATE 103 36 <xml><thread name="Thread-17" id="pid5740_seq19" /></xml>
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
I should break.
After the breakpoint
sending cmd: CMD_THREAD_SUSPEND 105 38 <xml><thread id="pid5740_seq12" stop_reason="111"><frame id="97199496" name="index" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Capplications%255Cgeorgstestapp%255Ccontrollers%255Ctest.py" line="12">"</frame><frame id="95957960" name="%26lt%3Blambda%26gt%3B" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cglobals.py" line="172">"</frame><frame id="100912680" name="%26lt%3Bmodule%26gt%3B" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Capplications%255Cgeorgstestapp%255Ccontrollers%255Ctest.py" line="19">"</frame><frame id="66219576" name="restricted" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Crestricted.py" line="204">"</frame><frame id="96138760" name="run_controller_in" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Ccompileapp.py" line="537">"</frame><frame id="96513256" name="serve_controller" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cmain.py" line="202">"</frame><frame id="62835496" name="wsgibase" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cmain.py" line="493">"</frame><frame id="62834872" name="app_with_logging" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Cmain.py" line="676">"</frame><frame id="96071288" name="run_app" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Crocket.py" line="1994">"</frame><frame id="66212296" name="run" file="c%253A%255Cmisc%255Cweb2py_src%255Cweb2py%255Cgluon%255Crocket.py" line="1302">"</frame><frame id="95948632" name="__bootstrap_inner" file="c%253A%255Cpython27%255Clib%255Cthreading.py" line="530">"</frame><frame id="96053672" name="__bootstrap" file="c%253A%255Cpython27%255Clib%255Cthreading.py" line="503">"</frame></thread></xml>
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
('received command ', '106\t17\tpid5740_seq12')
('processing internal command ', '<pydevd_comm.InternalRunThread instance at 0x0000000005F82E88>')
I should break.
After the breakpoint
sending cmd: CMD_THREAD_RUN 106 40 pid5740_seq12 None
The behavior does not change. The breakpoint in app B is ignored, while the one in app A works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题,我无法让断点工作(pydev 断点不起作用)。
还没有解决方案,但也许知道我没有使用 web2py 是有用的。
I have run into a similar problem, where i could not get breakpoints to work (pydev breakpoints not working).
No solution yet, but maybe it is useful to know that i am not using web2py.