Repository navigation
Hand each result over as soon as it arrives - #614
Merged
Merged
Conversation
The read stream held every message back until the server sent the next one. That let a payload download overlap the wait for the next message, but it also meant a result reached the caller only when its successor arrived. The server sends results as they become ready and the gap between two of them can be long: a sheet image that is ready a few seconds into a read sat in the client, fully downloaded, until the first extracted values arrived many seconds later. The receive for the next message now runs as a task, and while it waits every message already received is handed over as soon as its own payload is downloaded. Order is unchanged, downloads still overlap the receive, and a stream that is abandoned or fails cancels the outstanding receive along with any downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HdXy5tRa4VgmTRHFLbygBx
jmtts
approved these changes
Oct 12, 2026
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.
The read stream (
Werk24Client.read_drawing) held every message back until the server sent the next one. The hold-back was there so a payload download could overlap the wait for the next message. Its side effect: a result reached the caller only when the result after it arrived.The server sends results as soon as each one is ready, and the gap between two can be long. A sheet image (
AskSheetImages) is typically ready a few seconds into a read, while the first extracted values come many seconds later. The image sat in the client, fully downloaded, for that whole gap.What changed (
_send_command_readinwerk24/techread.py)payload_bytes.recv()loses no data.recv()is called inside the task, so a receive cancelled before its first tick leaves no "coroutine was never awaited" warning.One semantic shift:
read_idle_timeoutnow starts when the previous message arrives, not when the caller next asks for one. It now measures server silence only, which is what its docstring says it bounds. Before, time the caller spent on a message was added to the window.Effect, replaying one real read's message schedule against a stubbed socket (seconds; the payload download is stubbed at 0.2s):
Tests
tests/test_shared_https_session.py. Two check that a message, with or without a payload, is handed over before the server sends the next one. The third checks that abandoning the stream cancels the outstanding receive..venv/bin/python -m pytest -m "not callback_e2e" -p no:cacheprovideron CPython 3.13.16: 1025 passed, 4 skipped, 1 deselected, 4 warnings. On main: 1023 passed, with the same 4 warnings.Questions for the owner
One question. It does not block the merge.
Not questions, for after the merge:
🤖 Generated with Claude Code
https://claude.ai/code/session_01HdXy5tRa4VgmTRHFLbygBx
Generated by Claude Code