In perl debugger I can use DB::get_fork_TTY() to debug both parent and child process in different terminals. Is there anything similar in python debugger? Or, is there any good way to debug fork in python?
在perl调试器中,我可以使用DB :: get_fork_TTY()来调试不同终端中的父进程和子进程。 python调试器中有类似的东西吗?或者,有没有什么好方法在python中调试fork?
5 个解决方案
#1
-12
But I'm still curious if there's any similar feature in python debugger. I happen to find this feature in perldb and I find it's very handy
但是我仍然很好奇,如果python调试器中有任何类似的功能。我碰巧在perldb中找到了这个功能,我发现它非常方便
No.
没有。
You don't need it.
你不需要它。
No matter how handy it may appear in other environments, you just don't need it.
无论它在其他环境中出现多么方便,你都不需要它。
You don't need fork()
in Python; therefore you don't need fancy debugging to work with fork()
.
你不需要Python中的fork();因此,您不需要花哨的调试来使用fork()。
If you think you need fork()
you should either use subprocess
, multiprocessing
or C.
如果您认为需要fork(),则应使用子进程,多处理或C.
#2
2
You can emulate forked process if you will set instead of fork and its condition (pid == 0) always True. For debugging main process debugger will work.
如果您将设置而不是fork并且其条件(pid == 0)始终为True,则可以模拟分叉进程。对于调试主进程调试器将起作用。
For debugging multi-processing interaction better to use detailed logs as for me
对于调试多处理交互,更好地使用详细日志和我一样
#3
1
The debugger in pyCharm does this nicely. It seems to use gdb with python support to accomplish that, however all the tutorials on how to do this with gdb by Hand which I've found so far didn't work for me. In pyCharm it just works.
pyCharm中的调试器可以很好地完成这项工作。似乎使用gdb和python支持来实现这一点,但是到目前为止我发现的所有关于如何使用Gdb手工编写的教程对我来说都不起作用。在pyCharm它只是工作。
#4
0
One possible way to debug a fork is to use pdb on the main process and winpdb on the fork. You put a software break early in the fork process and attach the winpdb app once the break has been hit.
调试fork的一种可能方法是在主进程上使用pdb,在fork上使用winpdb。你在fork进程的早期放置了一个软件中断,并在中断后关闭winpdb应用程序。
It might be possible to run the program under winpdb and attach another instance after the fork - I haven't tried this. You certainly can't attach two winpdb instances at the same time, I've tried and it fails. If it works, this would be preferable - pdb really sucks.
有可能在winpdb下运行程序并在fork之后附加另一个实例 - 我没试过这个。你当然不能同时附加两个winpdb实例,我已经尝试过它失败了。如果它工作,这将是更好的 - pdb真的很糟糕。
#5
0
Provided Python has not been stripped of its debugging symbols and gdb (version above 7.0) is available, you can attach to the child and use pdb commands to debug it with:
如果Python没有被剥离其调试符号并且gdb(7.0以上版本)可用,您可以附加到子节点并使用pdb命令来调试它:
pdb-clone --pid CHILD_PID
pdb-clone is at Pypi: http://pypi.python.org/pypi/pdb-clone/
pdb-clone位于Pypi:http://pypi.python.org/pypi/pdb-clone/
#1
-12
But I'm still curious if there's any similar feature in python debugger. I happen to find this feature in perldb and I find it's very handy
但是我仍然很好奇,如果python调试器中有任何类似的功能。我碰巧在perldb中找到了这个功能,我发现它非常方便
No.
没有。
You don't need it.
你不需要它。
No matter how handy it may appear in other environments, you just don't need it.
无论它在其他环境中出现多么方便,你都不需要它。
You don't need fork()
in Python; therefore you don't need fancy debugging to work with fork()
.
你不需要Python中的fork();因此,您不需要花哨的调试来使用fork()。
If you think you need fork()
you should either use subprocess
, multiprocessing
or C.
如果您认为需要fork(),则应使用子进程,多处理或C.
#2
2
You can emulate forked process if you will set instead of fork and its condition (pid == 0) always True. For debugging main process debugger will work.
如果您将设置而不是fork并且其条件(pid == 0)始终为True,则可以模拟分叉进程。对于调试主进程调试器将起作用。
For debugging multi-processing interaction better to use detailed logs as for me
对于调试多处理交互,更好地使用详细日志和我一样
#3
1
The debugger in pyCharm does this nicely. It seems to use gdb with python support to accomplish that, however all the tutorials on how to do this with gdb by Hand which I've found so far didn't work for me. In pyCharm it just works.
pyCharm中的调试器可以很好地完成这项工作。似乎使用gdb和python支持来实现这一点,但是到目前为止我发现的所有关于如何使用Gdb手工编写的教程对我来说都不起作用。在pyCharm它只是工作。
#4
0
One possible way to debug a fork is to use pdb on the main process and winpdb on the fork. You put a software break early in the fork process and attach the winpdb app once the break has been hit.
调试fork的一种可能方法是在主进程上使用pdb,在fork上使用winpdb。你在fork进程的早期放置了一个软件中断,并在中断后关闭winpdb应用程序。
It might be possible to run the program under winpdb and attach another instance after the fork - I haven't tried this. You certainly can't attach two winpdb instances at the same time, I've tried and it fails. If it works, this would be preferable - pdb really sucks.
有可能在winpdb下运行程序并在fork之后附加另一个实例 - 我没试过这个。你当然不能同时附加两个winpdb实例,我已经尝试过它失败了。如果它工作,这将是更好的 - pdb真的很糟糕。
#5
0
Provided Python has not been stripped of its debugging symbols and gdb (version above 7.0) is available, you can attach to the child and use pdb commands to debug it with:
如果Python没有被剥离其调试符号并且gdb(7.0以上版本)可用,您可以附加到子节点并使用pdb命令来调试它:
pdb-clone --pid CHILD_PID
pdb-clone is at Pypi: http://pypi.python.org/pypi/pdb-clone/
pdb-clone位于Pypi:http://pypi.python.org/pypi/pdb-clone/