[英]Run Background Process in Python
I know that I can run a background process in python using subprocess.我知道我可以使用子进程在 python 中运行后台进程。 But the problem is that when I make a gui and then use subprocess with
close_fds=True
parameter, the window changes to not responding.但问题是,当我制作一个 gui 然后使用带有
close_fds=True
参数的子close_fds=True
,窗口变为不响应。
So, what I want is that I need to create a background process but it should run separately along with the main process and when that process is done, it should again combine with the main process.所以,我想要的是我需要创建一个后台进程,但它应该与主进程一起运行,当该进程完成后,它应该再次与主进程结合。
BTW, I am using PySide2 as the gui framework顺便说一句,我使用 PySide2 作为 gui 框架
Any help would be appreciated任何帮助,将不胜感激
I think what would be more beneficial to you would be threading, you are able to start a process in another thread without blocking the main thread which runs your gui.我认为对你更有益的是线程,你可以在另一个线程中启动一个进程而不会阻塞运行你的 gui 的主线程。 Once the other thread has completed its task it will join the main thread
一旦另一个线程完成其任务,它将加入主线程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.