Repository navigation
Conversation
planetf1
approved these changes
Jul 30, 2026
planetf1
left a comment
Contributor
There was a problem hiding this comment.
Clean fix. The on_timeout wiring correctly closes the leak described in the deleted TODOs — direct avalue()/astream() calls now signal the worker thread on stream timeout. The callback isolation (errors logged and suppressed, not propagated) is the right contract. Test coverage is solid: both generation paths have end-to-end timeout tests, and the four send_to_queue cases cover the key behavioural boundaries.
Signal the Hugging Face cancellation event when the per-chunk stream guard expires so direct avalue and astream calls do not leave generation running in a worker thread. Cover standard and KV-cache streaming paths, callback failures, normal completion, and backend-originated timeouts. Assisted-by: Hermes Agent Assisted-by: Claude Signed-off-by: Joshua Nwachinemere <[email protected]>
dk3yyyy
force-pushed
the
fix/1242-hf-timeout-cancellation
branch
from
July 30, 2026 20:47
bcb6fa7 to
d0630ec
Compare
ajbozarth
approved these changes
Jul 31, 2026
ajbozarth
left a comment
Member
There was a problem hiding this comment.
Also LGTM, thank you for the contribution
Merged
via the queue into
generative-computing:main
with commit Jul 31, 2026
5643e21
10 checks passed
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.
Pull Request
Issue
Fixes #1242
Description
Hugging Face generation runs in a worker thread with a cooperative cancellation event. When Mellea's per-chunk stream guard timed out, direct
avalue()andastream()calls raised the timeout without signaling that event, so generation continued in the background until natural completion.This change adds an optional timeout callback to
send_to_queue()and connects it to the Hugging Face cancellation hook in both the standard and KV-cache streaming paths. The callback runs only when Mellea's own stream guard expires. Backend-raisedTimeoutErrorinstances remain unchanged, and callback failures cannot replace the original stream timeout.Testing
Local verification:
uv run pytest --no-cov -q test/helpers/test_async_helpers.py test/backends/test_huggingface_unit.py(74 passed)uv run pre-commit run --all-files(all hooks passed, including Ruff, MyPy, uv-lock, codespell, license headers, markdownlint, and generated MDX validation)Attribution
Adding a new component, requirement, sampling strategy, or tool?
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.