MCPcopy Create free account
hub / github.com/PRIME-RL/PRIME / time_limit

Function time_limit

data_preprocessing/math_util/grader.py:389–398  ·  view source on GitHub ↗
(seconds: float)

Source from the content-addressed store, hash-verified

387
388@contextlib.contextmanager
389def time_limit(seconds: float):
390 def signal_handler(signum, frame):
391 raise TimeoutException("Timed out!")
392
393 signal.setitimer(signal.ITIMER_REAL, seconds)
394 signal.signal(signal.SIGALRM, signal_handler)
395 try:
396 yield
397 finally:
398 signal.setitimer(signal.ITIMER_REAL, 0)
399
400
401def format_intervals(prediction):

Callers 2

_parseFunction · 0.70
symbolic_equalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected