开发者

Pausing a process in Windows

I'm making a nice little Python GUI frontend for ffmpeg on Windows (one that is specifically designed to convert videos to an iPhone-friendly format and automatically import it to iTunes and tag it), and I want it to work so that you can pause the process and resume it if you want.

Since I start ffmpeg as a separate process, the obvious solution would be for the program to suspend the process (which I know is possible in Windows, Process Explorer can do it), but I c开发者_运维知识库an't figure out how to do it. Does anyone have any idea how to do this in Python?


You can easily do this by using psutil ( https://github.com/giampaolo/psutil ):

import psutil
pid = 1034  # replace this with the pid of your process
p = psutil.Process(pid)
p.suspend()

...to resume it:

p.resume()

Internally this is implemented in C by using SuspendThread() and ResumeThread() Windows system calls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜