-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtournament_online.py
46 lines (38 loc) · 1.26 KB
/
tournament_online.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import argparse
from colosseum.tournament_online import _push_metric, online_tournament
def _handle_exception(exception):
try:
_push_metric(
name="colosseum_worker_errors",
values={"value": 1},
tags={
"source": "colosseum_worker",
"error_class": exception.__class__.__name__,
},
)
except Exception as e:
print(
f"failed to handle exception {exception} with the following exception: {e}"
)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run tournament matches from an API")
parser.add_argument("--loop", action="store_true", help="Runs in a loop")
parser.add_argument(
"--game", action="store", help="Specify a particular game to be ran"
)
kwargs = vars(parser.parse_args())
loop = kwargs.pop("loop")
if loop:
while True:
try:
online_tournament(**kwargs)
except Exception as e:
_handle_exception(e)
print(f"tournament failed with: {e}")
else:
try:
online_tournament(**kwargs)
except Exception as e:
_handle_exception(e)
raise