我看到有关如何调试挂起进程的python模块的建议 [英] I see advice on how to debug a python module that hangs up theprocess

查看:87
本文介绍了我看到有关如何调试挂起进程的python模块的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是另一个Python问题,我认为可能与我发现的早期错误无关,并且最终想出了如何将
报告给Sourceforge。 />

这与我关于Python挂起来的问题有关,或者从shell中挂起,或者通过导入模块。我不会考虑一个bug,但更多的是因为我对Python缺乏经验。


如果我的代码导致Python挂断,而不允许我

与control-C或control-D爆发,有没有办法让
找出发生了什么?我不认为它会进入一些

无限循环,因为我通常可以用

control-C来突破它们。什么会导致Python运行时系统

只是松散的东西?控制台已经死了,但是回显''''''''''''''''''''''''''''''''''''''''''''''我可以释放它的唯一方法是杀死这个过程。


有人可以联系

via电话带我走过这个? (假设我不能在这里得到足够的

信息?还是有人关心Python漏洞?)这是在OpenBSD上的
Python 2.3.3c1(虽然我怀疑操作系统很重要)。我运行程序并且Python锁定的症状



。我无法控制-C或

控制-D

来摆脱它;我必须单独登录并杀死-9进程。



进程列为D +进程。虽然它挂起了,虽然看起来好像没有b $ b访问磁盘,我很确定没有磁盘问题

(虽然

我不是在物理上靠近服务器,所以我无法检查驱动器LED。)


我该如何调试?有Python工具吗?或者应该



使用gdb?的ktrace? systrace?我假设我必须这样做,作为一个错误

报告

读取Python锁定并不是太有用。


John

This is another Python problem, I think might be unrelated to
the earlier bug I found, and eventually figured out how to
report it to Sourceforge.

This is related to a question I have about Python hanging up
either from a shell, or by importing a module. This I would not
consider a bug, but more on my inexperience with Python.

If my code causes Python to just hang up, and not allowing me
to break out with control-C or control-D, is there a way to
find out what''s going on? I don''t think it''s going into some
infinite loop, because I can usually break out of them with
control-C. What would cause the Python run-time system
to just loose things? The console is dead, but it echo''s
carriage returns but that''s all it does. The only way I can
release it, is to kill the process.

Is there someone who I might contact
via phone to walk me through this? (Assuming I can''t get adequate
information here? Or does anyone care about Python bugs?) This is in
Python 2.3.3c1 on OpenBSD (though I doubt the OS matters). The symptom
is
that I run my program and Python locks up. I cannot control-C or
control-D
to get out of it; I have to log in separately and kill -9 the process.
The
process is listed as "D+" while it is hung, though it doesn''t seem to be
accessing the disk, and I''m quite sure there are no disk problems
(though
I''m not physically next to the server, so I can''t check the drive LED).

How should I approach debugging this? Are there Python tools? Or should
I
use gdb? ktrace? systrace? I''m assuming I have to do this, as a bug
report
which reads "Python locks up" isn''t too useful.

John

推荐答案

JD< li *** @ webcrunchers .COM>写道:

[挂起的Python程序的剪辑问题]
JD <li***@webcrunchers.com> wrote:
[snip problem with Python program that hangs]
我应该如何调试这个?有Python工具吗?或者应该
我使用gdb?的ktrace? systrace?我假设我必须这样做,因为一个错误报告
其中包含Python锁定的错误。并不是太有用。
How should I approach debugging this? Are there Python tools? Or should
I
use gdb? ktrace? systrace? I''m assuming I have to do this, as a bug
report
which reads "Python locks up" isn''t too useful.




我建议的第一步是在周围撒上打印报表

你的代码:


print"即将调用some_func()......"

some_func()

print"返回来自通话some_func()..."


然后你可以看到控制台输出(或者将它重定向到一个文件以便稍后阅读
)并查看东西挂起来。


-

Robin Munn
rm * **@pobox.com




2003年12月16日下午2:45,Robin Munn写道:

On Dec 16, 2003, at 2:45 PM, Robin Munn wrote:
我建议的第一步是在你的代码周围撒上打印声明:

print"即将调用some_func() ..."
some_func()
print"从调用some_func()返回..."

然后你可以看到控制台输出(或重定向到一份文件 (稍后阅读)并查看事情何时挂起。
The first step I''d suggest is to sprinkle print statements all around
your code:

print "About to call some_func()..."
some_func()
print "Returned from calling some_func()..."

Then you can watch the console output (or redirect it to a file for
later perusal) and see when the thing hangs.




我们已经知道它挂起的功能。这是一个Python函数

我们定义了。


显然,我们在

的开头放了一个打印声明错误

功能,但它似乎没有到达那里。


IE:


打印在函数调用之前

my_function(some_arguments)

print"函数调用后


def my_function(some_arguments) :

print" start of function call" < ---这永远不会被调用,或者

我们看不到输出

<其余代码>


所以当这段代码被调用时,我们得到:


在函数调用之前

< system hangs up>


然后,我们必须做一个kill -9。这个过程。


John



We already know the function it hangs up at. It''s a Python function
we defined.

Obviously, we put a print statement right at the beginning of the
errant
function, but it doesn''t appear to be getting there.

IE:

print "before function call"
my_function(some_arguments)
print "after function call"

def my_function(some_arguments):
print "start of function call" <--- this never gets called, or
we don''t see the output
<rest of code>

So when this piece of code is called, we get:

before function call
<system hangs up>

Then, we have to do a "kill -9" the process.

John


JD< li *** @ webcrunchers.com>写道:
JD <li***@webcrunchers.com> writes:
print"在函数调用之前"
my_function(some_arguments)
print"函数调用后
print "before function call"
my_function(some_arguments)
print "after function call"




有什么争论?也许他们的评价是悬而未决的。



What are the arguments? Maybe their evaluation is hanging somehow.


这篇关于我看到有关如何调试挂起进程的python模块的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆