bash - Python, run a shell script as soon as the previous iteration ends. -


i trying write simple program call shell script. need shell script executed continuously, however, not in given time interval, since can't know how long take process created shell script finish. have used threading run script every n seconds. need is, "test.sh" ends, run "test.sh" again.

this current code.

import subprocess import threading  looptime = 7.0  def recognize():     threading.timer(looptime,recognize).start()     filepath = "/home/user/downloads/image.jpg"      output = subprocess.check_output(['dir/test.sh',str(filepath)])     print ("python print\n%s" % output)  recognize() 

you don't need threading.timer. subprocess.check_outputwill block main process until child process finished.

import subprocess  def recognize():     filepath = "/home/user/downloads/image.jpg"      output = subprocess.check_output(['dir/test.sh',str(filepath)])     print ("python print\n%s" % output)  while true:     recognize() 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -