From 5c2690aad568b527bca2a247b633135a08cd6e4c Mon Sep 17 00:00:00 2001 From: Yongzao <532741407@qq.com> Date: Thu, 31 Oct 2024 05:52:05 +0800 Subject: [PATCH] [CI/Build] Simplify exception trace in api server tests (#9787) Signed-off-by: youkaichao Co-authored-by: youkaichao Signed-off-by: Loc Huynh --- tests/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index f6f588df48810..e8aad9cb3268f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -133,15 +133,19 @@ def _wait_for_server(self, *, url: str, timeout: float): 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: