Skip to content

fix crash on client disconnect (Ctrl+C)#4308

Merged
lvhan028 merged 3 commits intoInternLM:mainfrom
lvhan028:fix-abort
Feb 2, 2026
Merged

fix crash on client disconnect (Ctrl+C)#4308
lvhan028 merged 3 commits intoInternLM:mainfrom
lvhan028:fix-abort

Conversation

@lvhan028
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 30, 2026 04:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a crash that occurs when a client disconnects (e.g., via Ctrl+C) by improving exception handling in the async infrastructure. The changes address race conditions and ensure proper cleanup of resources during client disconnections.

Changes:

  • Added a check to prevent setting a result on an already-completed future in the StreamingSemaphore
  • Improved exception handling for client disconnects (asyncio.CancelledError, GeneratorExit) with proper async cancellation
  • Added backend-specific cleanup logic for PyTorch backend in the safe_run exception handler

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lmdeploy/turbomind/turbomind.py Adds future.done() check before setting result to prevent InvalidStateError on already-completed futures
lmdeploy/serve/managers/session_manager.py Updates exception handling to catch CancelledError and GeneratorExit, removes redundant async_end call for SafeRunException, and improves logging consistency
lmdeploy/serve/core/async_engine.py Adds PyTorch-specific session cleanup in safe_run exception handler to ensure proper resource release

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lvhan028 lvhan028 requested a review from lzhangzz January 30, 2026 04:38
@lvhan028 lvhan028 requested a review from irexyc January 30, 2026 04:47
@lvhan028 lvhan028 merged commit 975803b into InternLM:main Feb 2, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants