fix: preserve per-session ordering in BufferedMessageHandler#166
fix: preserve per-session ordering in BufferedMessageHandler#166Andy963 wants to merge 1 commit intobubbuild:mainfrom
Conversation
|
Thank you for this vibe efforts, but this PR requires a significant amount of review effort from me, and it feels like it's not quite right. To ensure a single worker, a queue with a single consumer is sufficient; this architecture is even simpler than the original, but this change has made things significantly more complex. Furthermore, for comma commands, jump-the-queue processing is reasonable, and maintaining order is not a requirement. In addition, the execution of |
Summary
This PR fixes per-session ordering in
BufferedMessageHandler.The previous implementation could run
_handlerconcurrently for the same session because_in_processingwas cleared beforeawait self._handler(...)completed. It also mixed command handling and buffered message timing in a way that could break expected per-session ordering semantics.This change replaces the shared timer/event batching flow with a head-driven serialized work queue:
This keeps strict arrival-order serialization while still allowing non-command messages to be batched.
What changed
BufferedMessageHandlerto use a per-session queued work model_pending_messages/_event/_timerprocessing flowTests
uv run ruff check .uv run mypy srcuv run pytest -q tests/test_channels.pyuv run pytest -quv run prek run --all-filesFixes #<165>