← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #269254]: Wait until the process is completed

 

Question #269254 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/269254

    Status: Open => Answered

RaiMan proposed the following answer:
the docs for Jython subprocess.Popen
http://www.jython.org/docs/library/subprocess.html

there is Popen.poll() that can be used to check, wether the subprocess has terminated or not.
Furthermore it does not look like you want to use the output to STDOUT of the called program, so you should not specify the stdout parameter.

BTW: I would never name a variable the same as a used module or class.

while True:
  # ... some code
  if typei == '1':
    url = '/getsome' + rid
    args = ('C:\file.exe', '--silent' + url)
    myApp = subprocess.Popen(args)
    hasTerminated = False
    shouldStop = time.time() + 180
    while not hasTerminated:
      ret = myApp.poll()
      if ret:
        hasTerminated = True
        break
      if time.time() > shouldStop:
        myApp.terminate()
        break
  if not hasTerminated:
    continue

# code in case it terminated within 180 secs

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.