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

python - PyInstaller UAC not working in onefile mode -

4x4 Matrix in Python -

wso2is - WSO2 IS 5.0.0 SP1 After restart there is authentication error -