Skip to content

Commit

Permalink
fix: duplicate stacktrace on engine error
Browse files Browse the repository at this point in the history
Signed-off-by: Wallas Santos <[email protected]>
  • Loading branch information
wallashss authored and dtrifiro committed Oct 24, 2024
1 parent d66fff7 commit 23ae5db
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vllm_tgis_adapter/grpc/grpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from grpc_health.v1 import health, health_pb2, health_pb2_grpc
from grpc_reflection.v1alpha import reflection
from vllm.engine.async_llm_engine import AsyncLLMEngine
from vllm.engine.multiprocessing import MQEngineDeadError
from vllm.entrypoints.openai.serving_completion import merge_async_iterators
from vllm.inputs import LLMInputs
from vllm.sampling_params import RequestOutputKind, SamplingParams
Expand Down Expand Up @@ -149,6 +150,9 @@ async def _handle_exception(
service_metrics.count_request_failure(FailureReasonLabel.GENERATE)
else:
service_metrics.count_request_failure(FailureReasonLabel.UNKNOWN)
if isinstance(e, MQEngineDeadError):
logger.error(e)
return
logger.exception("%s failed", func.__name__)
raise e

Expand Down
33 changes: 33 additions & 0 deletions tests/test_grpc_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

import pytest

from .utils import GrpcClient
Expand Down Expand Up @@ -90,3 +92,34 @@ def test_request_id(grpc_client, mocker):

spy.assert_called_once()
assert spy.spy_return == request_id.hex


def test_error_handling(mocker):
from vllm.engine.multiprocessing import MQEngineDeadError

from vllm_tgis_adapter.grpc.grpc_server import _handle_exception, logger

def dummy_func():
pass

class DummyEngine:
errored = False
is_running = True

class DummyArg:
engine = DummyEngine()

# General error handling
key_error = KeyError()
dummy_arg_0 = DummyArg()
with pytest.raises(KeyError):
asyncio.run(_handle_exception(key_error, dummy_func, dummy_arg_0))

engine_error = MQEngineDeadError("foo:bar")

# Engine error handling
spy = mocker.spy(logger, "error")

# Does not raises exception
asyncio.run(_handle_exception(engine_error, dummy_func, dummy_arg_0))
spy.assert_called_once_with(engine_error)

0 comments on commit 23ae5db

Please sign in to comment.