Skip to content

Commit 77b7857

Browse files
authored
[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.
1 parent 78b69f0 commit 77b7857

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

python/mlc_llm/serve/engine_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ def terminate(self):
659659
if hasattr(self, "_terminated") and self._terminated:
660660
return
661661
self._terminated = True
662+
if not hasattr(self, "_ffi"):
663+
return
662664
self._ffi["exit_background_loop"]()
663665
if hasattr(self, "_background_loop_thread"):
664666
self._background_loop_thread.join()

0 commit comments

Comments
 (0)