[ez] Provide a slightly better error message if process times out (#117865)

Just a slightly clearer error message
Pull Request resolved: https://github.com/pytorch/pytorch/pull/117865
Approved by: https://github.com/malfet, https://github.com/huydhn
This commit is contained in:
Catherine Lee
2024-01-19 22:58:00 +00:00
committed by PyTorch MergeBot
parent 29f899ef87
commit 5538b37a06

View File

@ -829,7 +829,7 @@ def wait_for_process(p, timeout=None):
else:
p.kill()
raise
except subprocess.TimeoutExpired:
except subprocess.TimeoutExpired as timeout_exception:
# send SIGINT to give pytest a chance to make xml
p.send_signal(signal.SIGINT)
exit_status = None
@ -843,7 +843,9 @@ def wait_for_process(p, timeout=None):
return exit_status
else:
p.kill()
raise
# Provide more info about the timeout (specifically that it timed out
# after the keyboard interrupt as well)
raise RuntimeError(f"Subprocess failed to exit smoothly after timeout {timeout} expired") from timeout_exception
except: # noqa: B001,E722, copied from python core library
p.kill()
raise