3

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 can't figure out how to do it. Does anyone have any idea how to do this in Python?

Charlie Salts
  • 13,109
  • 7
  • 49
  • 78
Oskar
  • 889
  • 7
  • 20

1 Answers1

6

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.

Giampaolo Rodolà
  • 12,488
  • 6
  • 68
  • 60