Skip to content

fix(server): stop bare excepts from swallowing cancellation and shutdown - #1557

Open
harshadkhetpal wants to merge 1 commit into
ModelTC:mainfrom
harshadkhetpal:fix/server-bare-excepts
Open

fix(server): stop bare excepts from swallowing cancellation and shutdown#1557
harshadkhetpal wants to merge 1 commit into
ModelTC:mainfrom
harshadkhetpal:fix/server-bare-excepts

Conversation

@harshadkhetpal

Copy link
Copy Markdown

Summary

Replaces the 18 bare except: clauses in lightllm/server/ (ruff E722). A bare except catches BaseException, which in an async serving stack silently swallows asyncio.CancelledError, KeyboardInterrupt, and SystemExit — 8 of these sites are in httpserver_for_pd_master/manager.py, on the PD-master request lifecycle (abort fallbacks, status updates, request-table cleanup), where an eaten cancellation can leak or hang a request instead of unwinding it.

Chosen replacements:

  • except Exception: for the 15 intentional catch-and-continue sites — identical behavior for all ordinary errors, but cancellation/shutdown now propagates.
  • except (AttributeError, TypeError): for the two chat_template capability probes in build_prompt.py (the only failures attribute probing produces).
  • except OSError: for the temp-file unlink cleanup in embed_cache/afs_utils.py.

Testing

python -m py_compile passes on all nine files; ruff check --select E722 on lightllm/server/ goes from 18 errors to clean. No functional change for ordinary exceptions — only BaseException-family propagation is restored.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Harshad Khetpal <harshadkhetpal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant