[Tutor] I may have solved my problem with killing tasks in Windows
ian-campbell at shaw.ca
Sat Apr 25 21:49:57 CEST 2009
I am trying to use this so maybe no one has to reply... sorry to
I got it from Google but did not copy his name and cannot give my
thanks to original author, sorry.
from win32event import WaitForSingleObject, WAIT_TIMEOUT
from win32api import TerminateProcess
def execute_and_wait(args, timeout=None):
"""Execute a command and wait until termination. If timeout elapses
and still not finished, kill it.
args: list containing program and arguments, or a single string.
timeout: maximum time to wait, in ms, or None.
p = subprocess.Popen(args)
ret = WaitForSingleObject(p._handle, timeout)
ret = execute_and_wait(["notepad", "c:\\BuyLiveHit.ahk"], 5000)
More information about the Tutor