Skip to content

Run the async client on trio as well as asyncio - #48

Open
Om-Beast wants to merge 3 commits into
prooflinedev:mainfrom
Om-Beast:fix/async-client-trio-backend
Open

Om-Beast wants to merge 3 commits into
prooflinedev:mainfrom
Om-Beast:fix/async-client-trio-backend

Conversation

@Om-Beast

@Om-Beast Om-Beast commented Nov 14, 2026 •

Copy link
Copy Markdown

Problem

AsyncProoflineClient uses asyncio.sleep for retry backoff and review polling, although its async HTTP transport supports AnyIO. Under Trio, a retried 429/503 can become a misleading HTTP 0 invalid-response error, and polling a running review raises RuntimeError: no running event loop.

Changes

  • Use AnyIO sleep for async retries and wait_for_review(), preserving existing retry, deadline, and exact-head polling behavior.
  • Exercise asyncio and Trio with real loopback HTTP regressions for 429/503 backoff, polling deadlines, exact-head completion and mismatch after a polling sleep, and a stalled response body.
  • Keep Trio as a development-only dependency and document that users install it separately to use the Trio backend.
  • Merge upstream main at 8e94310. The resolved lock preserves all 41 upstream entries, including their versions, markers, and hashes; the additional entries support the Trio tests.

Verification

  • Against unmodified upstream code at 8e94310, the branch's retry/polling regressions reproduce the issue: 3 asyncio cases pass and 3 Trio cases fail.
  • python scripts/check.py on Python 3.12.14: 230 tests passed, including all 12 backend regression cases.
  • /usr/bin/python3.13 scripts/check.py on Python 3.13.5: 230 tests passed, including all 12 backend regression cases.
  • Both full checks passed generation, HTTP/outcome contracts, Ruff lint and format, mypy, wheel and source distribution builds, and installed sync/async HTTP smoke tests.
  • git diff --check passes; GitHub reports the branch as mergeable.

AsyncProoflineClient bounds I/O with anyio, but its Retry-After backoff
and wait_for_review polling slept with asyncio.sleep. Under trio a
retried request surfaced as a status-0 invalid-response problem and
wait_for_review raised "no running event loop". Sleep with anyio so both
paths run on any backend that anyio and httpx support, and test the
sleeping and deadline paths on asyncio and trio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GA2KNDKv463GeBmDCYL95
@Om-Beast

Copy link
Copy Markdown
Author

Proofline review

I installed Proofline on my fork and ran it on the same commit (1844f51) through a fork-internal PR: Om-Beast/sdk-python#1. The check finished in about a minute with no findings.

How I evaluated it:

  • No findings matches what I verified independently. The trio tests fail on main and pass with the change, and the full scripts/check.py (ruff, mypy, 146 tests, build, install smoke) is green. I don't see a missed defect.
  • The walkthrough explained the wrong part of the change. It walked through the Trio dev dependency and the README sentence, and listed client.py, _transport.py and tests/test_async_backends.py as "3 changed files not explained above". Those three files hold the actual behaviour change (the two asyncio.sleep → anyio.sleep swaps) and its regression tests. A reviewer reading only the walkthrough would not learn why the PR exists. I'd expect a walkthrough to rank the files that change runtime behaviour above the dependency and doc edits.
  • What I changed as a result: nothing in the code, since there were no findings. I kept the PR description's "Problem" section explicit about the two call sites and their failure modes, so the reasoning the walkthrough skipped is in the PR itself.

mohsen1 commented Nov 17, 2026

Copy link
Copy Markdown
Member

Codex review: Please resolve the client/transport/dependency conflicts against current main, preserving exact-head polling and the current dependency pins. Keep anyio sleeps in both async retry and polling paths, retain the Trio regressions, and rerun scripts/check.py.

Retain exact-head review polling and every existing dependency lock entry. Exercise retry backoff, pinned-head polling and request deadlines on both asyncio and Trio.

Copy link
Copy Markdown
Author

@mohsen1 Thanks for the review. Resolved the conflicts in eeae462, preserving exact-head polling, the existing dependency pins, and both AnyIO sleeps. scripts/check.py passes locally with all 230 tests, including the Trio regressions.

Could you please approve the workflow and help with the Proofline seat requirement blocking the gate? Thank you!

Copy link
Copy Markdown
Author

Hi @mohsen1, thanks again for the review. I've updated the branch in 399f948, merging current main at 8e94310 and resolving the new requirements-dev.txt conflict.

  • Preserved exact-head polling and both AnyIO sleep paths. All 41 existing upstream lock entries retain their versions, markers, and hashes; the additional entries are Trio's development dependencies.
  • On unmodified 8e94310, the retry/polling regressions reproduce: 3 asyncio cases pass and 3 Trio cases fail. On this commit, scripts/check.py passes on Python 3.12.14 and 3.13.5: 230 tests each, including all 12 backend cases. Generation, contracts, lint, typing, and wheel/sdist install smoke checks also pass.

GitHub now reports the branch as mergeable. The new Checks workflow requires maintainer action, and the Proofline gate still says the author needs a seat. When you have a chance, could you please help with those two blockers? Thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants