implemented event delay with dummy listener,

event delay listener in data.py unimplemented


Former-commit-id: dea5f3a374
This commit is contained in:
Arthur Lu 2021-10-10 06:15:22 +00:00
parent 56d3a0adcd
commit 32ae4fd636
2 changed files with 21 additions and 8 deletions

View File

@ -186,3 +186,7 @@ def push_pit(apikey, competition, pit):
for variable in pit: for variable in pit:
push_team_pit_data(apikey, competition, variable, pit[variable]) push_team_pit_data(apikey, competition, variable, pit[variable])
def check_new_database_matches(client, competition):
return True

View File

@ -158,7 +158,7 @@ import warnings
import websockets import websockets
from interface import splash, log, ERR, INF, stdout, stderr from interface import splash, log, ERR, INF, stdout, stderr
from data import get_previous_time, set_current_time, load_match, push_match, load_pit, push_pit from data import get_previous_time, set_current_time, load_match, push_match, load_pit, push_pit, check_new_database_matches
from processing import matchloop, metricloop, pitloop from processing import matchloop, metricloop, pitloop
config_path = "config.json" config_path = "config.json"
@ -207,7 +207,7 @@ sample_json = """{
"attitude":true "attitude":true
} }
}, },
"even-delay":false, "event-delay":false,
"loop-delay":60 "loop-delay":60
}""" }"""
@ -383,11 +383,20 @@ def main(send, verbose = False, profile = False):
set_current_time(client, current_time) set_current_time(client, current_time)
send(stdout, INF, "finished all tests in " + str(time.time() - loop_start) + " seconds, looping") send(stdout, INF, "finished all tests in " + str(time.time() - loop_start) + " seconds, looping")
loop_delay = float(config["loop-delay"]) event_delay = config["event-delay"]
remaining_time = loop_delay - (time.time() - loop_start) if event_delay:
if remaining_time > 0: send(stdout, INF, "loop delayed until database returns new matches")
send(stdout, INF, "loop delayed by " + str(remaining_time) + " seconds") new_match = False
time.sleep(remaining_time) while not new_match:
time.sleep(1)
new_match = check_new_database_matches(client, competition)
send(stdout, INF, "database returned new matches")
else:
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: except KeyboardInterrupt:
send(stdout, INF, "detected KeyboardInterrupt, killing threads") send(stdout, INF, "detected KeyboardInterrupt, killing threads")