From 77b7857bbefd4baa4e70e3b5e3d70b0ee9daac73 Mon Sep 17 00:00:00 2001 From: Ruihang Lai Date: Thu, 21 Nov 2024 11:15:02 -0500 Subject: [PATCH] [Python] Skip termination when engine is not initialized (#3040) 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()