分析fuse-python
我目前正在使用fuse-python 编写一个fuse。它已经在做它应该做的事情了。然而,安装几周后,速度明显变得缓慢。所以我想介绍一下它。我知道有几个可以优化的地方。但罪魁祸首不应该是这些。
但是,fuse-python 挂在无限循环中(请参阅 熔丝源的第733行和757行)。如果我在调试模式下运行熔断器(使用 -d
开关),它将在前台运行。但是,我无法使用 SIGINT
或 CTRL+C
(无论如何都是相同的)来阻止它。
我尝试使用 signal
模块在主线程中捕获信号。但这也行不通。有趣的是,一旦我使用 SIGKILL
停止该进程,我就会在 stdout
上看到 KeyboardInterrupt
。此外,在 SIGKILL
之后,信号处理程序将按预期执行。
这会对分析产生影响。由于进程永远不会正常终止,cProfile
永远没有机会保存统计文件。
有什么想法吗?
I am currently writing a fuse using fuse-python. It's already doing what it should. However, after it's mounted for a few weeks, it's becoming noticeably slow. So I wanted to profile it. I know about a few point where it could be optimized. But these should not be the culprits.
However, fuse-python hangs in an infinite loop (see line 733 and 757 of the fuse source). If I run fuse in debug mode (using the -d
switch), it will run in foreground. However, I cannot stop it with SIGINT
nor with CTRL+C
(which is anyway the same).
I tried to use the signal
module to trap the signal in the main thread. But this does not work either. Interestingly, once I shoot the process down with SIGKILL
, I see the KeyboardInterrupt
on stdout
. Also, after a SIGKILL
, the signal handler is executed as expected.
This has repercussions on profiling. As the process never terminates normally, cProfile
never gets the chance to save the stats file.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Python 安装一个在
SIGINT 上引发
。如果在调用 fusion 的 main 时检测到非默认信号处理程序,它将 不要用自己的处理程序替换,通常会调用KeyboardInterrupt
的处理程序fuse_session_exit
和 清理。调用fuse的main之后,KeyboardInterrupt
被CFUNCTYPE
包装器吞没,你永远不会看到他们。您的选择是:
SIGQUIT
Ctrl+\,或除SIGINT
之外的任何其他终止信号。但是保险丝不会完全退出。SIGINT
中,并在完成后恢复原始信号处理程序。我强烈建议您也切换到替代绑定,fuse-python 非常混乱且难以使用。我在 fusepy 方面运气很好,并在那里提交了一些补丁。
当您能够在不使用未捕获信号的情况下终止 FUSE 实例时,Python 分析器将能够正常保存统计信息。
Python installs a handler that raises
KeyboardInterrupt
onSIGINT
. If a non-default signal handler is detected when fuse's main is called, it will not replace the handler with its own, which normally callsfuse_session_exit
and cleans up. After you've called fuse's main, theKeyboardInterrupt
is swallowed byCFUNCTYPE
wrappers and you never see them.Your options are to:
SIGQUIT
by pressing Ctrl+\, or any other terminating signal other thanSIGINT
. However fuse will not exit cleanly.SIGINT
before calling fuse's main, and restore the original when you're done.I'd highly recommend you switch to an alternative binding also, fuse-python is terribly messy and difficult to work with. I've had a lot of luck with fusepy, and have submitted a few patches there.
When you're able to terminate your FUSE instance without using uncaught signals, the Python profiler will be able to save the stats as per normal.