gpt4 book ai didi

python - cProfile 配置文件在线程内调用吗?

转载 作者:太空狗 更新时间:2023-10-30 02:23:42 26 4
gpt4 key购买 nike

我在一些代码上运行了 cprofile,除其他外,它产生了几个线程来完成大部分工作。当我查看分析的输出时,我没有看到线程内调用的所有函数的日志记录。我确定他们被调用了,因为他们做的事情很容易看到,例如写入数据库等。

cProfile 不分析线程吗?我错过了什么吗?

最佳答案

在这里找到答案:link

It's worth pointing out that using the profiler only works (by default) on the main thread, and you won't get any information from other threads if you use them. This can be a bit of a gotcha as it is completely unmentioned in the profiler documentation. If you also want to profile threads, you'll want to look at the threading.setprofile() function in the docs.

关于python - cProfile 配置文件在线程内调用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2522452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com