分析fuse-python

发布于 2024-10-17 20:05:34 字数 750 浏览 1 评论 0原文

我目前正在使用fuse-python 编写一个fuse。它已经在做它应该做的事情了。然而,安装几周后,速度明显变得缓慢。所以我想介绍一下它。我知道有几个可以优化的地方。但罪魁祸首不应该是这些。

但是,fuse-python 挂在无限循环中(请参阅 熔丝源的第733行和757行)。如果我在调试模式下运行熔断器(使用 -d 开关),它将在前台运行。但是,我无法使用 SIGINTCTRL+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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

年少掌心 2024-10-24 20:05:34

Python 安装一个在 SIGINT 上引发 KeyboardInterrupt 的处理程序。如果在调用 fusion 的 main 时检测到非默认信号处理程序,它将 不要用自己的处理程序替换,通常会调用 fuse_session_exit清理。调用fuse的main之后,KeyboardInterruptCFUNCTYPE 包装器吞没,你永远不会看到他们。

您的选择是:

  • 通过按 发送 SIGQUIT Ctrl+\,或除 SIGINT 之外的任何其他终止信号。但是保险丝不会完全退出。
  • 在调用 fusion 的 main 之前,将默认信号处理程序安装到 SIGINT 中,并在完成后恢复原始信号处理程序。
old_handler =signal(SIGINT, SIG_DFL)
# call main
signal(SIGINT, old_handler)

我强烈建议您也切换到替代绑定,fuse-python 非常混乱且难以使用。我在 fusepy 方面运气很好,并在那里提交了一些补丁。

当您能够在不使用未捕获信号的情况下终止 FUSE 实例时,Python 分析器将能够正常保存统计信息。

Python installs a handler that raises KeyboardInterrupt on SIGINT. 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 calls fuse_session_exit and cleans up. After you've called fuse's main, the KeyboardInterrupt is swallowed by CFUNCTYPE wrappers and you never see them.

Your options are to:

  • Send SIGQUIT by pressing Ctrl+\, or any other terminating signal other than SIGINT. However fuse will not exit cleanly.
  • Install the default signal handler to SIGINT before calling fuse's main, and restore the original when you're done.
old_handler =signal(SIGINT, SIG_DFL)
# call main
signal(SIGINT, old_handler)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文