fix: stop uvicorn threads during shutdown - #737
Open
Ricky-7-Yan wants to merge 1 commit into
Open
Conversation
Ricky-7-Yan
requested review from
Abdul-0x4A,
andyland,
dmitsf,
ethanwharris,
justusschock,
k223kim and
tchaton
as code owners
August 30, 2026 18:31
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Threaddoes not provide, leaving the server hanging or logging an attribute errorThis 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 setsforce_exit. Process workers keep their current behaviorValidation:
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.pyruff format --check src/litserve/server.py tests/unit/test_lit_server.pyBefore submitting
PR review
Anyone in the community is free to review the PR once the tests have passed
Did you have fun?
Yes