- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在 django(1.4) 中实现一个中间件,以使用 PyCallGraph 创建调用图 。我是根据网上找到的两个不同的片段来编写的。它看起来像这样:
import time
from django.conf import settings
from pycallgraph import Config
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput
class CallgraphMiddleware(object):
def process_view(self, request, callback, callback_args, callback_kwargs):
if settings.DEBUG and 'graph' in request.GET:
config = Config()
config.trace_filter = GlobbingFilter(exclude=['pycallgraph.*','*.secret_function',], include=['reports.*'])
graphviz = GraphvizOutput(output_file='callgraph-' + str(time.time()) + '.png')
pycallgraph = PyCallGraph(output=graphviz, config=config)
pycallgraph.start()
self.pycallgraph = pycallgraph
def process_response(self, request, response):
if settings.DEBUG and 'graph' in request.GET:
self.pycallgraph.done()
return response
我已将其添加到 settings.py
上安装的其他中间件中,然后启动服务器。
它似乎在调用 process_view
时触发,但当它到达 process_response
时,django 提示,告诉我 'CallgraphMiddleware' 对象没有属性 'pycallgraph'
.这怎么可能?显然这条线
self.pycallgraph = pycallgraph
不考虑
。为什么?
最佳答案
我确实忘记导入 GlobbingFilter
所以我遇到了一个异常,不会让代码运行到 self.pycallgraph = pycallgraph
PyCharm 也未正确配置。我解决了,感谢这个答案:
https://stackoverflow.com/a/20335280/1191416
关于python - django 中的 PyCallGraph 中间件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29776107/
我逐字运行了以下代码(这是官方示例代码): http://pycallgraph.slowchop.com/en/master/examples/basic.html 我收到以下错误: 'The co
我正在使用 windows 7,python 2.7 和 pip 8.0.2 我已经在 cygwin 中使用 pip 安装了 pyCallGraph for python pip install py
我正在尝试在 django(1.4) 中实现一个中间件,以使用 PyCallGraph 创建调用图 。我是根据网上找到的两个不同的片段来编写的。它看起来像这样: import time from dj
我正在使用 mac os x 并尝试设置 pycallgraph。 我用 pip 安装了 pycallgraph,用 homebrew 安装了 graphviz。 一切都在 shell 中工作。但不是
我想看看我一直在处理的 python3 包中的特定操作发生了什么。我使用 pycallgraph,它看起来很棒。但我不知道如何从输出中删除整个调用树。 我制作了一个快速脚本make_call_grap
我是一名优秀的程序员,十分优秀!