Repository navigation
Land two open community fixes: non-blocking input in async examples (#216), monotonic PollTimer (#204) - #224
Open
deanrie wants to merge 2 commits into
Conversation
This was referenced Oct 16, 2026
(cherry picked from commit 0640e80)
PollTimer measured elapsed duration with time.time(), a wall clock. NTP corrections, manual clock changes or VM suspend/restore move it: a forward adjustment can make an otherwise healthy deferred chat, collection indexing or video-generation poll time out immediately, and a backward adjustment can extend polling beyond the caller's requested timeout. Both the sync and async polling paths share this helper. Use time.monotonic(), which cannot go backward, for the start timestamp and the elapsed-time computation. No public API change and no normal-case timing change. Fixes xai-org#203 (cherry picked from commit 5bddbf1)
deanrie
force-pushed
the
community/protobuf7-async-examples-poll-timer
branch
from
October 24, 2026 08:23
8a31b3f to
b29ab76
Compare
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
Two community fixes that have each sat open and MERGEABLE for over a month with no review, cherry-picked onto current
mainwith their original authorship so they can land in one pass. No changes to the patches themselves beyond the rebase.Use asyncio.to_thread for non-blocking input in async chat examples(fix: use asyncio.to_thread for non-blocking input in async chat examples #216, @bodapatisaikrishna, 2026-09-18). The README andexamples/aio/chat.pycalled blockinginput()insideasync defloops; nowawait asyncio.to_thread(input, "You: "). Fixes [BUG] Blocking Synchronous I/O in Async Example Code (README.md) #213.fix: account polling elapsed time on the monotonic clock(fix: account polling elapsed time on the monotonic clock #204, @yzxcj797, 2026-09-07).PollTimermeasured elapsed time withtime.time(), so an NTP step or DST change during a poll could fire the timeout early or never; nowtime.monotonic(), with tests. Fixes [BUG] Polling timeouts can misfire after wall-clock adjustments #203.The protobuf 7 commit (#183) that this PR originally carried first landed on
mainthrough #223 and shipped in v1.21.0, so it has been dropped here; the branch is rebased onto the release.If the maintainers prefer to merge the originals individually, this PR can be closed; it exists so the two do not need two separate review passes.
Verification (local,
uv sync --locked, after the rebase onto v1.21.0)ruff format --checkandruff check: clean.pyright: 0 errors.pytest -n 4: 872 passed.Fixes #213, #203. Supersedes #216, #204 if merged.