From b9fe4616f98b77b4b9458bce203aa6544cb31ef2 Mon Sep 17 00:00:00 2001 From: Jerry Yang Date: Fri, 15 Sep 2023 08:40:18 +0800 Subject: [PATCH] Abort when coroutine is cancelled (#1020) --- vllm/engine/async_llm_engine.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vllm/engine/async_llm_engine.py b/vllm/engine/async_llm_engine.py index 1a52f0262d55..a83a602d0222 100644 --- a/vllm/engine/async_llm_engine.py +++ b/vllm/engine/async_llm_engine.py @@ -395,8 +395,9 @@ class AsyncLLMEngine: async for request_output in stream: yield request_output - except Exception as e: - # If there is an exception, abort the request. + except (Exception, asyncio.CancelledError) as e: + # If there is an exception or coroutine is cancelled, abort the + # request. self._abort(request_id) raise e