【发布时间】:2013-05-16 16:08:12
【问题描述】:
假设我在一个相当复杂的 Flask 应用程序中有两个函数。一个函数调用另一个函数。
def dispatch_unlock(...):
# ... stuff ...
log('dis start')
# this routine just sends some data over a ZMQ IPC socket
# in this scenario, the socket send will time out
ret = acl.enqueue(unlock.id, endpoint_id, filter_entry['service_id'])
log('dis end')
return ret
def something_else(...);
# ... stuff ...
log('routecall start')
ret = dispatch_unlock(unlock, endpoint_id, endpoint, f)
log('routecall end')
return ret
something_else 运行时,会产生以下输出:
routecall start
dis start
dis end
之后,它就挂断了。我尝试转储 Python 堆栈跟踪,但它们没有显示任何有用的信息。一个堆栈跟踪位于 Werkzurg 重新加载器中,另一个是通向 SIGUSR1 调用的转储程序的堆栈跟踪。
谁能建议到底发生了什么? Python 调用堆栈是否以某种方式损坏?
编辑:这是我在返回之前单步执行时pdb 显示的内容。看起来dispatch_unlock 的调用框架上方的框架不知何故丢失了。
> /SourceCache/Florence/lib/plugin/route.py(27)dispatch_unlock()
-> return ret
(Pdb) s
--Return--
> /SourceCache/Florence/lib/plugin/route.py(27)dispatch_unlock()->None
-> return ret
(Pdb) s
【问题讨论】:
-
acl.enqueue是什么? python 在返回值时可能会挂起的一种情况是,如果函数内部调用了不能正确处理异常的 C 扩展,并且sys.excepthook被替换为虚假函数;但我认为情况并非如此......