简体   繁体   English

python:如何调试多进程? (使用eclipse+pydev)

[英]python: How to debug multiprocess? (using eclipse+pydev)

I've seen a couple of questions on the topic but I didn't get a full answer...我已经看到了有关该主题的几个问题,但我没有得到完整的答案...

My code is basically:我的代码基本上是:

from multiprocessing import Process

p = Process(target=f).start()
p.join()

def f():
  print 'break!'

And I want to put a breakpoint on the print .我想在print上放一个断点。 I'm using pydev+eclipse (on Ubuntu).我正在使用 pydev+eclipse(在 Ubuntu 上)。

Because the new process itself is not controlled by PyDev, you need to make PyDev debugger manually aware of through Remote Debugging facilities.由于新进程本身不受 PyDev 控制,因此您需要通过远程调试工具使 PyDev 调试器手动感知。

http://pydev.org/manual_adv_remote_debugger.html http://pydev.org/manual_adv_remote_debugger.html

Use pydevd.set_trace() - notice that your breakpoints won't work (not sure if this has changed recent PyDev versions), but you need to manually enter set_trace() command to your code.使用 pydevd.set_trace() - 注意你的断点不起作用(不确定这是否改变了最近的 PyDev 版本),但你需要手动输入 set_trace() 命令到你的代码中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM