Skip to content

Add real async iterator for ByteStreams#1036

Open
akx wants to merge 1 commit into
pydantic:mainfrom
akx:trio-bytestream-timeout-hx2
Open

Add real async iterator for ByteStreams#1036
akx wants to merge 1 commit into
pydantic:mainfrom
akx:trio-bytestream-timeout-hx2

Conversation

@akx

@akx akx commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Previously, __aiter__ was implemented as a generator function, and as such could get garbage collected when not completely exhausted in a way that has recent versions of trio complaining.

Using a real, if trivial, object to do this causes less complaints.

Port of my PR encode/httpx#3777

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
    • No need to.

Review in cubic

Previously, `__aiter__` was implemented as a generator function,
and as such could get garbage collected when not completely exhausted
in a way that has recent versions of `trio` complaining.

Using a real, if trivial, object to do this causes less complaints.

Fixes #3686
@codspeed-hq

codspeed-hq Bot commented Jun 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing akx:trio-bytestream-timeout-hx2 (1b58c6e) with main (82b9e2d)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

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.

1 participant