Hello, all professionals,
I used subprocess.Popen to launch a process, right now I am planning to shut it down after a given time. Can I use subprocess.kill() to fulfill that? (I do not know how to do that cuz every time I will receive a error message.)
import subprocess import time pid = subprocess.Popen(args = ["gonome-terminal", ""--command = xxxx"]).pid ''' this will launch a process as I specified in the second argument''' time.sleep(5.0) subprocess.kill(pid) '''Try to kill the process.'''
(However, I do not figure out how to fulfill this. Every time, there is an error says: 'unbound method kill() must be called with Popen instance as first argument (got int instance instead)'
Thank you for your considerations.
I appreciate all you helps
Edited by ljjfb: n/a