From 13e24c9c1d1a849601986010907c53599fa15a39 Mon Sep 17 00:00:00 2001 From: Ruihang Lai Date: Thu, 21 Nov 2024 10:56:27 -0500 Subject: [PATCH] [Python] Skip termination when engine is not initialized This PR skips the MLCEngine termination when the engine is not initialized at all (e.g., failed during JIT compilation). Previously there will be an extra error message saying `'MLCEngine' object has no attribute '_ffi'` which is confusing and misleading. Skipping the termination can eliminate this error message. --- python/mlc_llm/serve/engine_base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/mlc_llm/serve/engine_base.py b/python/mlc_llm/serve/engine_base.py index 0c7b908374..d038dd0282 100644 --- a/python/mlc_llm/serve/engine_base.py +++ b/python/mlc_llm/serve/engine_base.py @@ -659,6 +659,8 @@ def terminate(self): if hasattr(self, "_terminated") and self._terminated: return self._terminated = True + if not hasattr(self, "_ffi"): + return self._ffi["exit_background_loop"]() if hasattr(self, "_background_loop_thread"): self._background_loop_thread.join()