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

Function time_limit

eval/Coding/mbpp/evaluate_mbpp.py:88–96  ·  view source on GitHub ↗
(seconds: float)

Source from the content-addressed store, hash-verified

86 pass
87@contextlib.contextmanager
88def time_limit(seconds: float):
89 def signal_handler(signum, frame):
90 raise TimeoutException("Timed out!")
91 signal.setitimer(signal.ITIMER_REAL, seconds)
92 signal.signal(signal.SIGALRM, signal_handler)
93 try:
94 yield
95 finally:
96 signal.setitimer(signal.ITIMER_REAL, 0)
97
98def exec_helper(code):
99 with time_limit(3):

Callers 1

exec_helperFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected