本文介绍了使用 WingIDE 进行远程调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 WingIDE 调试 Web 应用程序,我在一些 Python 代码中设置了一个断点,该代码在提交 Web 表单时运行.就在断点之前,我插入了import wingdbstub"来激活远程调试.但是,执行不会在断点处停止.我知道代码正在运行,因为如果我在断点之前插入引发异常(sys.modules)",执行将停止并且我的浏览器中会出现回溯,显示 wingdbstub 已加载.

Using WingIDE to debug a web application, I have set a breakpoint in some Python code which runs when a web-form is submitted. Just before the breakpoint I have inserted 'import wingdbstub' to activate remote deubgging. However, execution does not stop at the breakpoint. I know the code is running because if I insert 'raise exception(sys.modules)' just before the breakpoint, execution stops and a traceback appears in my browser, showing wingdbstub is loaded.

如果我将鼠标悬停在状态栏中的错误图标上,则会出现一个对话框,显示无调试进程/正在侦听 TCP/IP 50005 上的连接.允许主机 127.0.0.1".我知道当 a) 错误图标从绿色变为白色,并且 b) 调试工具栏按钮(步入、结束、退出等)消失时,我已经失去"了调试模式.

If I hover over the bug icon in the status-bar, a dialog says "No debug process / listening for connections on TCP/IP 50005. Allowed hosts 127.0.0.1". I know I have 'lost' debug mode when a) the bug icon changes from green to white, and b) the debugging toolbar buttons (step into, over, out, etc.) disappear.

我尝试删除已编译的 .pyc 文件,以便它们在模块下次运行时重新编译,但问题仍然存在.

I tried deleting compiled .pyc files so that they recompile when the module next runs, but the problem remains.

如何检查 Wing 是否正在侦听正确的端口?奇怪的是,远程调试有时会起作用,但大多数时候不起作用.

How can I check if Wing is listening on the correct port? The strange thing is that remote-debugging has worked sometimes, but most of the time it doesn't.

任何帮助将不胜感激.作为记录,我使用的是 Python 3.1、CherryPy 3.20 和 WingIDE Personal 3.2.11.

Any help would be appreciated. For the record, I am using Python 3.1, CherryPy 3.20 and WingIDE Personal 3.2.11.

艾伦

推荐答案

在 Windows 下,我遇到过您提到的相同行为,即远程调试有时有效,但经常卡住".我发现一些有助于解决这种情况的事情:

Under Windows, I've experienced the same behavior you mention, i.e., remote debugging sometimes works, but often 'gets stuck'. I've found a few things helpful in resolving this situation:

  1. 确保您的防火墙没有阻止进出 WingIDE 使用的端口和正在调试的进程的流量.(就我而言,我必须取消阻止 wing.exe 我试图在 Windows 防火墙中调试的程序.)
  2. 确保在调试会话失败后没有积累任何僵尸 python 进程.这些可以保持与 IDE 的打开连接,使新生成的实例无法连接.(在 Windows 下,您可以使用 tasklist 命令检查正在运行的 python 实例,netstat -anp tcp 将显示任何卡在 TIME_WAIT 状态的套接字.)
  3. import wingdbstub 语句之后立即插入 time.sleep(10) 调用.从控制台启动程序,确保它连接到 IDE(调试图标将变为绿色),然后点击 IDE 中的暂停"按钮,然后点击退出".(我无法开始解释原因,但在调试连接不稳定后,这似乎为我解决了几次问题.)
  1. Make sure your firewall isn't blocking traffic to/from the ports being used by WingIDE and the process being debugged. (In my case, I had to unblock both wing.exe and the program I was attempting to debug in Windows Firewall.)
  2. Make sure you haven't accumulated any zombie python processes after failed debug sessions. These can hold open a connection to the IDE, making it impossible for a newly-spawned instance to connect. (Under Windows, you can use the tasklist command to check for running python instances, and netstat -anp tcp will show any sockets stuck in the TIME_WAIT state.)
  3. Insert a time.sleep(10) call immediately after your import wingdbstub statement. Start the program from a console, make sure it connects in the IDE (debug icon will turn green), then hit the 'Pause' button in the IDE, followed by 'Step Out'. (I can't begin to explain why, but this appeared to right the ship for me a couple of times after the debug connection had gone wonky.)

上述建议可能也适用于 Linux,但到目前为止我只在 Windows 下遇到过这个问题......

The above advice probably applies to Linux as well, but I've only experienced this problem under Windows so far...

这篇关于使用 WingIDE 进行远程调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 08:24