Skip to content

fix: stop uvicorn threads during shutdown - #737

Open
Ricky-7-Yan wants to merge 1 commit into
Lightning-AI:mainfrom
Ricky-7-Yan:fix/windows-uvicorn-thread-shutdown
Open

fix: stop uvicorn threads during shutdown#737
Ricky-7-Yan wants to merge 1 commit into
Lightning-AI:mainfrom
Ricky-7-Yan:fix/windows-uvicorn-thread-shutdown

Conversation

@Ricky-7-Yan

Copy link
Copy Markdown

What does this PR do?

Fixes #684

On Windows, LitServe runs each Uvicorn server in a thread. The shutdown path treated those threads like multiprocessing workers and called methods that threading.Thread does not provide, leaving the server hanging or logging an attribute error

This change gives Uvicorn worker threads the same small lifecycle surface used by the existing shutdown loop. terminate() requests Uvicorn's graceful exit, while the existing timeout fallback sets force_exit. Process workers keep their current behavior

Validation:

  • pytest tests/unit/test_lit_server.py::test_uvicorn_thread_shutdown_signals -q (1 passed)
  • ruff check src/litserve/server.py tests/unit/test_lit_server.py
  • ruff format --check src/litserve/server.py tests/unit/test_lit_server.py
Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs? Not needed for this internal lifecycle fix
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed

Did you have fun?

Yes

@codecov-commenter

codecov-commenter commented Aug 31, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85%. Comparing base (4c9fecc) to head (d79162f).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #737   +/-   ##
===================================
- Coverage    85%    85%   -0%     
===================================
  Files        39     39           
  Lines      3285   3293    +8     
===================================
+ Hits       2781   2787    +6     
- Misses      504    506    +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Threads not properly killed on windows

2 participants