Repository navigation
fix(channels): clear _in_processing on task cancellation or batch error - #409
Open
KuljeetSinghXDA wants to merge 1 commit into
Open
KuljeetSinghXDA wants to merge 1 commit into
KuljeetSinghXDA wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Summary
Fixes
BufferedMessageHandlerinsrc/bub/channels/handler.pyso a cancelled or failed batch task cannot permanently wedge message processing for a session.Previously,
self._in_processing = Noneonly ran sequentially inside_process()afterChannelMessage.from_batch(self._pending_messages). If_process()was cancelled while waiting (or before its firstawait) or iffrom_batch()raised,self._in_processingremained non-Noneforever and subsequent messages were appended to_pending_messageswithout ever scheduling_process().Changes
src/bub/channels/handler.py:_ensure_processing/_clear_processingwith a task done-callback andtry ... finallyin_process()so_in_processingis always cleared on normal completion, cancellation, or error._pending_messagesbefore callingChannelMessage.from_batch.tests/test_channels.py: added regression tests for cancellation before processing andfrom_batchfailure recovery.Verification
uv run ruff check src/bub/channels/handler.py tests/test_channels.py: passeduv run mypy src:Success: no issues found in 77 source filesuv run pytest tests/test_channels.py -q: 89 passed