mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-18 10:46:58 +08:00
[Bugfix][Frontend/Core] Don't log exception when AsyncLLMEngine gracefully shuts down. (#5290)
This commit is contained in:
parent
065aff6c16
commit
0f83ddd4d7
@ -29,23 +29,32 @@ class AsyncEngineDeadError(RuntimeError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _raise_exception_on_finish(
|
def _log_task_completion(task: asyncio.Task,
|
||||||
task: asyncio.Task, error_callback: Callable[[Exception],
|
error_callback: Callable[[Exception], None]) -> None:
|
||||||
None]) -> None:
|
"""This function is only intended for the `engine.run_engine_loop()` task.
|
||||||
msg = ("Task finished unexpectedly. This should never happen! "
|
|
||||||
"Please open an issue on Github.")
|
In particular, that task runs a `while True` loop that can only exit if
|
||||||
|
there is an exception.
|
||||||
|
"""
|
||||||
|
|
||||||
exception = None
|
exception = None
|
||||||
try:
|
try:
|
||||||
task.result()
|
return_value = task.result()
|
||||||
# NOTE: This will be thrown if task exits normally (which it should not)
|
raise AssertionError(
|
||||||
raise AsyncEngineDeadError(msg)
|
f"The engine background task should never finish without an "
|
||||||
|
f"exception. {return_value}")
|
||||||
|
except asyncio.exceptions.CancelledError:
|
||||||
|
# We assume that if the task is cancelled, we are gracefully shutting
|
||||||
|
# down. This should only happen on program exit.
|
||||||
|
logger.info("Engine is gracefully shutting down.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exception = e
|
exception = e
|
||||||
logger.error("Engine background task failed", exc_info=e)
|
logger.error("Engine background task failed", exc_info=e)
|
||||||
error_callback(exception)
|
error_callback(exception)
|
||||||
raise AsyncEngineDeadError(
|
raise AsyncEngineDeadError(
|
||||||
msg + " See stack trace above for the actual cause.") from e
|
"Task finished unexpectedly. This should never happen! "
|
||||||
|
"Please open an issue on Github. See stack trace above for the"
|
||||||
|
"actual cause.") from e
|
||||||
|
|
||||||
|
|
||||||
class AsyncStream:
|
class AsyncStream:
|
||||||
@ -438,8 +447,7 @@ class AsyncLLMEngine:
|
|||||||
self._background_loop_unshielded = asyncio.get_event_loop(
|
self._background_loop_unshielded = asyncio.get_event_loop(
|
||||||
).create_task(self.run_engine_loop())
|
).create_task(self.run_engine_loop())
|
||||||
self._background_loop_unshielded.add_done_callback(
|
self._background_loop_unshielded.add_done_callback(
|
||||||
partial(_raise_exception_on_finish,
|
partial(_log_task_completion, error_callback=self._error_callback))
|
||||||
error_callback=self._error_callback))
|
|
||||||
self.background_loop = asyncio.shield(self._background_loop_unshielded)
|
self.background_loop = asyncio.shield(self._background_loop_unshielded)
|
||||||
|
|
||||||
def _init_engine(self, *args,
|
def _init_engine(self, *args,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user