Search code examples
pythonkill-processtaskkill

Want to kill my tab but process.kill() doesn't work


no error but still cannot kill the process

import time
import subprocess
total_breaks = 3
break_count = 0
print("This program started on " + time.ctime())
while(break_count < total_breaks):
    time.sleep(5)
    process = subprocess.Popen([r'F:\software\firefox\Firefox.exe',
'-new-tab', 'http://www.google.com/'])
    time.sleep(6)
    process.kill()
    break_count = break_count + 1

I expected to kill my tab because it ain't showing error but it doesn't work.


Solution

  • It worked automatically after reopening...I don't know why?