Skip to content

Conversation

@aniketmaurya
Copy link
Collaborator

@aniketmaurya aniketmaurya commented Jul 24, 2025

What does this PR do?

Devs won't see a lot of error msgs in the CI.

We exit the background process loop by sending (None, None, None) to the queue. We don't handle this gracefully and even though the loop is exited, we end up printing a lot of errors in the CI. This PR, will gracefully handle the termination for clearer CI.

Follow up

  • Clean the rest of the test errors

Changes

  • Added a new exception class _StopLoopError to handle sentinel values in request processing loops.
  • Updated collate_requests and loop classes to raise _StopLoopError when a sentinel value is encountered, allowing for clean exit from loops.
  • Refactored request handling in SingleLoop and StreamingLoop to improve clarity and maintainability.
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?
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

* Added a new exception class _StopLoopError to handle sentinel values in request processing loops.
* Updated collate_requests and loop classes to raise _StopLoopError when a sentinel value is encountered, allowing for clean exit from loops.
* Refactored request handling in SingleLoop and StreamingLoop to improve clarity and maintainability.
@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

Attention: Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85%. Comparing base (17f8ee0) to head (c0c7867).
Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #589   +/-   ##
===================================
- Coverage    85%    85%   -0%     
===================================
  Files        39     39           
  Lines      3017   3049   +32     
===================================
+ Hits       2564   2588   +24     
- Misses      453    461    +8     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aniketmaurya aniketmaurya changed the title wip: handle sentinel input in request_queue gracefully handle sentinel input in request_queue gracefully Jul 24, 2025
@aniketmaurya aniketmaurya requested a review from Copilot July 24, 2025 10:43
Copy link
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 introduces graceful handling of sentinel values in request queue processing to reduce failure messages in CI. It implements a new exception mechanism for cleanly exiting processing loops when shutdown signals are received.

  • Added _StopLoopError exception class for handling sentinel value shutdown signals
  • Updated all request processing loops to check for sentinel values and exit gracefully
  • Refactored request queue handling across streaming, single, and batched loops for consistency

Reviewed Changes

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

File Description
src/litserve/loops/base.py Added _StopLoopError exception and sentinel handling in collate_requests function
src/litserve/loops/simple_loops.py Updated single, async, and batched loops to handle sentinel values gracefully
src/litserve/loops/streaming_loops.py Added sentinel value detection and graceful exit in streaming loop
tests/unit/test_batch.py Added test coverage for sentinel value handling in collate_requests
Comments suppressed due to low confidence (1)

src/litserve/loops/simple_loops.py:301

  • The method call has been changed from collate_requests to self.get_batch_requests but the import for collate_requests was removed. This suggests get_batch_requests is being used instead, but this change is inconsistent with the other loops which still use collate_requests directly.
                batches, timed_out_uids = self.get_batch_requests(

* Introduced FakeTransport class to simulate message transport in tests.
* Updated test_batched_loop to utilize FakeTransport for response handling.
* Improved assertions to verify the correctness of responses from the batched loop.
@aniketmaurya aniketmaurya changed the title handle sentinel input in request_queue gracefully fix(ci): handle sentinel input in request_queue gracefully Jul 24, 2025
@aniketmaurya aniketmaurya merged commit e134f25 into main Jul 24, 2025
20 checks passed
@aniketmaurya aniketmaurya deleted the handle-sentinel-errors branch July 24, 2025 12:59
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.

2 participants