no SIGALRM on windows [pr] (#7104)

This commit is contained in:
George Hotz 2024-10-17 00:21:04 +08:00 committed by GitHub
commit eac58eaaba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,9 +55,10 @@ class TimeoutException(Exception): pass
def timeout_handler(signum, frame): raise TimeoutException()
def _try_compile_linearized_w_idx(x:Tuple[int,Kernel], compiler:Compiler) -> Tuple[int, Optional[Tuple[Program, bytes, float]]]:
signal.signal(signal.SIGALRM, timeout_handler)
# set timeout
signal.alarm(getenv("BEAM_TIMEOUT_SEC", 10))
if hasattr(signal, "SIGALRM"):
signal.signal(signal.SIGALRM, timeout_handler)
# set timeout
signal.alarm(getenv("BEAM_TIMEOUT_SEC", 10))
try:
p = x[1].to_program(name_override="test")
assert p.uops is not None, "uop list wasn't generated?"
@ -75,7 +76,7 @@ def _try_compile_linearized_w_idx(x:Tuple[int,Kernel], compiler:Compiler) -> Tup
if getenv("BEAM_STRICT_MODE"): raise e
ret = None
finally:
signal.alarm(0)
if hasattr(signal, "SIGALRM"): signal.alarm(0)
return x[0], ret
# workers should ignore ctrl c