Skip to content

Commit 7f1e6d5

Browse files
committed
skip slow scripts
1 parent fe72529 commit 7f1e6d5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tool/run.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sys
44
import time
5+
import signal
56
from collections import defaultdict
67
from typing import Mapping
78

@@ -16,6 +17,13 @@
1617
from tool.leaderboard.leaderboard import generate_leaderboard
1718

1819

20+
def maxDurationHandler(signum, frame):
21+
raise Exception("Maxiumum of 1s reached")
22+
23+
signal.signal(signal.SIGALRM, maxDurationHandler)
24+
25+
26+
1927
class DifferentAnswersException(Exception):
2028
pass
2129

@@ -63,18 +71,18 @@ def run(
6371
if restricted and input.author != submission.author.split(".")[0]:
6472
continue
6573
try:
74+
signal.alarm(1) # Start the 1s timer
6675
result = run_submission(
6776
problem, submission, input, previous, no_debug
6877
)
78+
signal.alarm(0) # Stop the timer
6979
results_by_author[submission.author].append(result)
7080
results_by_input[input.author].append(result)
7181
previous = result
7282
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})")
7886

7987
for submission in submissions:
8088
if submission.runnable is not None:

0 commit comments

Comments
 (0)