python cProfile 和配置文件模型跳过函数
基本上,当我运行 cProfile 模块时,它会跳过一些函数,而正常的配置文件模块会产生此错误。
The debugged program raised the exception unhandled AssertionError
"('Bad call', ('objects/controller/StageController.py', 9, '__init__'), <frame object at 0x9bbc104>, <frame object at 0x9bb438c>, <frame object at 0x9bd0554>, <frame object at 0x9bcf2f4>)"
File: /usr/lib/python2.6/profile.py, Line: 301
我完成了所有搜索,但找不到任何东西。我怎样才能让它们正常工作?
@yk4ever
StageController.py 类是这样开始的:
class StageControl(ObjectControl):
def __init__(self, canvas_name):
ObjectControl.__init__(self, canvas_name,"stage_object")
self.model = StageModel()
self.variables()
self.make_stage()
self.overrides()
上面的“Bad call”错误似乎不喜欢这个类
basically the cProfile module skips some functions when i run it, and the normal profile module produces this error.
The debugged program raised the exception unhandled AssertionError
"('Bad call', ('objects/controller/StageController.py', 9, '__init__'), <frame object at 0x9bbc104>, <frame object at 0x9bb438c>, <frame object at 0x9bd0554>, <frame object at 0x9bcf2f4>)"
File: /usr/lib/python2.6/profile.py, Line: 301
ive done all the searches and i cant find anything. How do i make them work properly?
@ yk4ever
StageController.py class starts like this:
class StageControl(ObjectControl):
def __init__(self, canvas_name):
ObjectControl.__init__(self, canvas_name,"stage_object")
self.model = StageModel()
self.variables()
self.make_stage()
self.overrides()
the "Bad call" error above seems to dislike this class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经找到问题了。 Psyco
我的“StageControl”继承的“ObjectControl”类有一个简单的:
在类内部,这导致了错误,因此只有继承“ObjectControl”的类中的方法导致探查器失败。我在某处读到,仅在必要时导入 psyco 是个好主意,事实证明这是一个坏主意。
我曾经使用过 psyco 一段时间,直到遇到 cython,但由于某种原因留下了 psyco 导入声明足够长的时间让分析器感到厌烦。我自从抛弃了psyco。
这个故事的寓意是:只要坚持使用 cython,最终没有什么比 C 更好的了。
I've found the problem. Psyco
the 'ObjectControl' class which my 'StageControl' inherited has a simple:
INSIDE the class, which caused the error hence only the methods in the classes which inherited 'ObjectControl', caused the profiler to fail. i read somewhere it was a good idea to import psyco only where it was necessary, turns out thats a bad idea.
I had used psyco for a time until i came across cython, but for some reason left the psyco import statements lying around long enough to bork the profiler. ive since dumped psyco.
the moral of the story is: just stick with cython, at the end of the day nothing beats C.
Python Bug #1117670 似乎描述了同样的问题。那里还附有一个用于重现类似问题的最小测试脚本。该错误已被标记为已修复。
请参阅上述 Python Bug 报告中的 msg24185,了解可在 Python 2.4 上使用的解决方法。
您使用哪个Python版本?
Python Bug #1117670 seems to describe the same issue. A minimal test script to reproduce that similar problem also attached there. The bug has been marked as fixed.
See msg24185 in the above Python Bug report for a workaround which can be used on Python 2.4.
Which Python version do you use?