Skip to content

Commit 4538344

Browse files
committed
improve error handling
1 parent 6287bf1 commit 4538344

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/model.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import os
3131
import queue
3232
import threading
33+
import traceback
3334
from typing import Dict, List
3435

3536
import numpy as np
@@ -244,7 +245,9 @@ def _init_engine(self):
244245
# failed to start, so the exception is passed back via the engine variable.
245246
if isinstance(self._llm_engine, Exception):
246247
e = self._llm_engine
247-
self.logger.log_error(f"[vllm] Failed to start engine: {e}")
248+
self.logger.log_error(
249+
f"[vllm] Failed to start engine: {traceback.format_exc()}"
250+
)
248251
if self._event_thread is not None:
249252
self._event_thread.join()
250253
self._event_thread = None
@@ -398,7 +401,7 @@ def _response_loop(self):
398401
response_state["is_cancelled"] = response_sender.is_cancelled()
399402
except Exception as e:
400403
self.logger.log_error(
401-
f"An error occurred while sending a response: {e}"
404+
f"An error occurred while sending a response: {traceback.format_exc()}"
402405
)
403406
finally:
404407
if response_flag == pb_utils.TRITONSERVER_RESPONSE_COMPLETE_FINAL:
@@ -533,7 +536,9 @@ async def _infer(self, request):
533536
)
534537

535538
except Exception as e:
536-
self.logger.log_error(f"[vllm] Error generating stream: {e}")
539+
self.logger.log_error(
540+
f"[vllm] Error generating stream: {traceback.format_exc()}"
541+
)
537542
error = pb_utils.TritonError(f"Error generating stream: {e}")
538543
text_output_tensor = pb_utils.Tensor(
539544
"text_output", np.asarray(["N/A"], dtype=self.output_dtype)
@@ -591,7 +596,7 @@ def _check_health(self, requests):
591596
future.result()
592597
except Exception as e:
593598
self.logger.log_error(
594-
f"[vllm] Engine is not healthy and model will be unloaded: {e}"
599+
f"[vllm] Engine is not healthy and model will be unloaded: {traceback.format_exc()}"
595600
)
596601
pb_utils.unload_model(self.model_config["name"]) # non-blocking
597602
self._is_healthy = False

0 commit comments

Comments
 (0)