[CI/Build] Simplify exception trace in api server tests (#9787)

Signed-off-by: youkaichao <youkaichao@gmail.com>
Co-authored-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
Yongzao 2024-10-31 05:52:05 +08:00 committed by GitHub
parent c2cd1a2142
commit 00d91c8a2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,15 +133,19 @@ class RemoteOpenAIServer:
try:
if requests.get(url).status_code == 200:
break
except Exception as err:
except Exception:
# this exception can only be raised by requests.get,
# which means the server is not ready yet.
# the stack trace is not useful, so we suppress it
# by using `raise from None`.
result = self.proc.poll()
if result is not None and result != 0:
raise RuntimeError("Server exited unexpectedly.") from err
raise RuntimeError("Server exited unexpectedly.") from None
time.sleep(0.5)
if time.time() - start > timeout:
raise RuntimeError(
"Server failed to start in time.") from err
"Server failed to start in time.") from None
@property
def url_root(self) -> str: