added test.py to .gitignore

prepared tra.py for threading implement

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2020-05-23 19:43:59 -05:00
parent 5aae889fd7
commit 7f689389d1

39
tra.py
View File

@ -27,13 +27,18 @@ def main():
global pit_enable global pit_enable
global config global config
config = su.load_config("config.json") global config = su.load_config("config.json")
while(True): task = threading.Thread(name = "match", target = match)
task.start()
task = threading.Thread(name = "match", target = metric)
task.start()
task = threading.Thread(name = "pit", target = pit)
task.start()
if match_enable == True and match == False: def match():
def target(): match = True
apikey = config["key"]["database"] apikey = config["key"]["database"]
competition = config["competition"] competition = config["competition"]
@ -43,15 +48,15 @@ def main():
su.matchloop(apikey, competition, data, tests) su.matchloop(apikey, competition, data, tests)
match = False match = False
return
match = True if match_enable == True and match == False:
task = threading.Thread(name = "match", target=target)
task = threading.Thread(name = "match", target = match)
task.start() task.start()
if metric_enable == True and metric == False: def metric():
def target(): metric = True
apikey = config["key"]["database"] apikey = config["key"]["database"]
tbakey = config["key"]["tba"] tbakey = config["key"]["tba"]
@ -63,15 +68,15 @@ def main():
su.metricloop(tbakey, apikey, competition, timestamp, metric) su.metricloop(tbakey, apikey, competition, timestamp, metric)
metric = False metric = False
return
match = True if metric_enable == True and metric == False:
task = threading.Thread(name = "metric", target=target)
task = threading.Thread(name = "match", target = metric)
task.start() task.start()
if pit_enable == True and pit == False: def pit():
def target(): pit = True
apikey = config["key"]["database"] apikey = config["key"]["database"]
competition = config["competition"] competition = config["competition"]
@ -81,10 +86,10 @@ def main():
su.pitloop(apikey, competition, data, tests) su.pitloop(apikey, competition, data, tests)
pit = False pit = False
return
pit = True if pit_enable == True and pit == False:
task = threading.Thread(name = "pit", target=target)
task = threading.Thread(name = "pit", target = pit)
task.start() task.start()
task = threading.Thread(name = "main", target=main) task = threading.Thread(name = "main", target=main)