Skip to content

Conversation

@njhill
Copy link
Member

@njhill njhill commented Sep 9, 2025

This fixes a bug where the asyncio event loop isn't properly obtained in the async engine client shutdown/finalizer logic.

(APIServer pid=769888)   File "/home/name/vllm_serve/.venv/lib/python3.12/site-packages/zmq/asyncio.py", line 116, in _default_loop
(APIServer pid=769888)     return asyncio.get_event_loop()
(APIServer pid=769888)            ^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=769888)   File "/usr/lib/python3.12/asyncio/events.py", line 702, in get_event_loop
(APIServer pid=769888)     raise RuntimeError('There is no current event loop in thread %r.'
(APIServer pid=769888) RuntimeError: There is no current event loop in thread 'MPClientEngineMonitor'

Fixes #24230.
Fixes #24305.

Co-authored-by: injaeryou <sts07142@naver.com>

Signed-off-by: Nick Hill <nhill@redhat.com>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves a critical bug in the asynchronous engine client's finalizer logic that caused a RuntimeError during shutdown. The fix correctly retrieves the asyncio event loop from the associated task, which is a much more robust approach than trying to get it from the current thread, especially within a finalizer that can be executed by the garbage collector. The additional safeguards, such as checking for a null loop and suppressing exceptions during task cancellation, further enhance the stability of the shutdown process. The changes are well-reasoned and correctly implemented.

@njhill njhill added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 10, 2025
@simon-mo simon-mo merged commit f88e840 into vllm-project:main Sep 10, 2025
46 of 48 checks passed
@njhill njhill deleted the fix-async-finalize branch September 10, 2025 04:40
skyloevil pushed a commit to skyloevil/vllm that referenced this pull request Sep 13, 2025
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
xuebwang-amd pushed a commit to xuebwang-amd/vllm that referenced this pull request Oct 10, 2025
Signed-off-by: Nick Hill <nhill@redhat.com>
Signed-off-by: xuebwang-amd <xuebwang@amd.com>
xuebwang-amd pushed a commit to xuebwang-amd/vllm that referenced this pull request Oct 24, 2025
Signed-off-by: Nick Hill <nhill@redhat.com>
Signed-off-by: xuebwang-amd <xuebwang@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

2 participants