Added intervalexec.py

This commit is contained in:
John Wiseman 2019-12-18 16:51:52 -08:00
parent b93c2f71d4
commit f529e8bcd3

26
intervalexec.py Normal file
View File

@ -0,0 +1,26 @@
import subprocess
import sys
import time
def run(args):
subprocess.run(args, check=True)
def main(args):
interval_secs = float(args[0])
exec_args = args[1:]
while True:
start_time = time.time()
next_time = start_time + interval_secs
run(exec_args)
now = time.time()
delay = next_time - now
if delay > 0.01:
time.sleep(delay)
if __name__ == '__main__':
main(sys.argv[1:])