diff --git a/src/cli/superscript.py b/src/cli/superscript.py index 91d11b5..c10b09a 100644 --- a/src/cli/superscript.py +++ b/src/cli/superscript.py @@ -14,6 +14,9 @@ __changelog__ = """changelog: - added verbose option to linux superscript to allow for interactive output - moved pymongo import to superscript.py - added profile option to linux superscript to profile runtime of script + - added event and time delay options to config + - event delay pauses loop until even listener recieves an update + - time delay pauses loop until the time specified has elapsed since the BEGINNING of previous loop 0.9.3: - improved data loading performance by removing redundant PyMongo client creation (120s to 14s) - passed singular instance of PyMongo client as standin for apikey parameter in all data.py functions @@ -203,7 +206,9 @@ sample_json = """{ "climb-mechanism":true, "attitude":true } - } + }, + "even-delay":false, + "loop-delay":60 }""" def main(send, verbose = False, profile = False): @@ -378,6 +383,12 @@ def main(send, verbose = False, profile = False): set_current_time(client, current_time) send(stdout, INF, "finished all tests in " + str(time.time() - loop_start) + " seconds, looping") + loop_delay = float(config["loop-delay"]) + remaining_time = loop_delay - (time.time() - loop_start) + if remaining_time > 0: + send(stdout, INF, "loop delayed by " + str(remaining_time) + " seconds") + time.sleep(remaining_time) + except KeyboardInterrupt: send(stdout, INF, "detected KeyboardInterrupt, killing threads") if "exec_threads" in locals():