fix: #175 BidiStream SIGTERM causes CPU hot loop and pod stuck in Terminating#176
Merged
igalshilman merged 6 commits intorestatedev:mainfrom Feb 26, 2026
Conversation
…uck in Terminating
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
|
Thanks a lot for creating this fix @brightsparc. cc @igalshilman for review. |
Contributor
Author
Cool, looking forward to getting this landed to reduce the hot loop when draining pods. |
igalshilman
reviewed
Feb 25, 2026
| assert isinstance(body, bytes) | ||
| # Skip empty body frames to avoid hot loop (see #175) | ||
| body = chunk.get("body", None) | ||
| if body is not None and len(body) > 0: |
igalshilman
approved these changes
Feb 26, 2026
Contributor
igalshilman
left a comment
There was a problem hiding this comment.
looks good! Thank you @brightsparc
Contributor
|
note to self: run verification tests once the docker image is built. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
fixes: #175
When a pod receives SIGTERM during an active BidiStream invocation, two bugs caused the worker to spin at ~82% CPU and never exit:
ReceiveChannel.__call__()blocked forever on an empty queue after the disconnect event was consumedcreate_poll_or_cancel_coroutine()fed empty body frames (b'') to the VM, creating a tight loop with no useful await pointsChanges
server_types.py: Return synthetichttp.disconnectwhen queue is drained and channel is disconnectedserver_context.py: Skipnotify_input()for empty body frames; add 30s timeout toblock_until_http_input_closed()inleave()tests/disconnect_hotloop.py: Regression tests for both fixes