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

Function time_limit

eval/utils/execution.py:91–99  ·  view source on GitHub ↗
(seconds: float)

Source from the content-addressed store, hash-verified

89
90@contextlib.contextmanager
91def time_limit(seconds: float):
92 def signal_handler(signum, frame):
93 raise TimeoutException("Timed out!")
94 signal.setitimer(signal.ITIMER_REAL, seconds)
95 signal.signal(signal.SIGALRM, signal_handler)
96 try:
97 yield
98 finally:
99 signal.setitimer(signal.ITIMER_REAL, 0)
100
101
102@contextlib.contextmanager

Callers 1

unsafe_executeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected