使用 PyInstaller 终止子进程

发布于 2024-10-07 11:29:21 字数 322 浏览 0 评论 0原文

我创建了一个使用 Python subprocess.Popen(...) 的脚本。当我单击按钮时,我想销毁这个子进程(我使用 subprocess.kill())。当我使用Python时它工作得很好。

但是,当我使用 PyInstaller“编译”我的脚本时,这不起作用。事实上,在任务管理器(Windows)中,有两个进程(其中一个来自临时目录[我猜是由 PyInstaller 创建的])。因此,当我单击该按钮时,进程会停止,但不会停止由 PyInstaller 创建的进程。

我怎样才能同时杀死2个进程?

Tkanks

PS:抱歉我的英语不好......

I created a script that uses Python subprocess.Popen(...). When I click a button, I want to destroy this subprocess (I use subprocess.kill()). It works fine when I use Python.

However, when I "compile" my script with PyInstaller, this doesn't work. Indeed, in the Task Manager (Windows), there are two processes (one from a temporary directory [created by PyInstaller I guess]). And so when I click the button, a process stops, but not one created by PyInstaller.

How can I do to kill the 2 processes at once ?

Tkanks

PS : Sorry for my bad english...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

花期渐远 2024-10-14 11:29:21

你试过编译这2个Python文件吗?使用 subprocess.Popen(...) 时必须使用第二个编译文件的路径

Have you tried to compile the 2 Python files? You have to use the path of the second compiled file when you use subprocess.Popen(...)

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