|
2 | 2 |
|
3 | 3 | import sys |
4 | 4 | import time |
| 5 | +import signal |
5 | 6 | from collections import defaultdict |
6 | 7 | from typing import Mapping |
7 | 8 |
|
|
16 | 17 | from tool.leaderboard.leaderboard import generate_leaderboard |
17 | 18 |
|
18 | 19 |
|
| 20 | +def maxDurationHandler(signum, frame): |
| 21 | + raise Exception("Maxiumum of 1s reached") |
| 22 | + |
| 23 | +signal.signal(signal.SIGALRM, maxDurationHandler) |
| 24 | + |
| 25 | + |
| 26 | + |
19 | 27 | class DifferentAnswersException(Exception): |
20 | 28 | pass |
21 | 29 |
|
@@ -63,18 +71,18 @@ def run( |
63 | 71 | if restricted and input.author != submission.author.split(".")[0]: |
64 | 72 | continue |
65 | 73 | try: |
| 74 | + signal.alarm(1) # Start the 1s timer |
66 | 75 | result = run_submission( |
67 | 76 | problem, submission, input, previous, no_debug |
68 | 77 | ) |
| 78 | + signal.alarm(0) # Stop the timer |
69 | 79 | results_by_author[submission.author].append(result) |
70 | 80 | results_by_input[input.author].append(result) |
71 | 81 | previous = result |
72 | 82 | except (DifferentAnswersException, UnexpectedDebugLinesException) as e: |
73 | | - errors.append( |
74 | | - f"{BColor.RED}ERROR: {e}{BColor.ENDC}".format( |
75 | | - BColor.RED, e, BColor.ENDC |
76 | | - ) |
77 | | - ) |
| 83 | + errors.append(f"{BColor.RED}ERROR: {e}{BColor.ENDC}") |
| 84 | + except Exception: |
| 85 | + errors.append(f"{BColor.RED}[{submission.author}] day-{submission.problem.day}/part-{submission.problem.part} ({submission.language}){BColor.ENDC}: Maxiumum of 1s reached (on input {BColor.BLUE}{input.author}{BColor.ENDC})") |
78 | 86 |
|
79 | 87 | for submission in submissions: |
80 | 88 | if submission.runnable is not None: |
|
0 commit comments