Add real async iterator for ByteStreams
AK
1mo ago+23+23+01234567890123456789-2-2-0123456789
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 https://github.com/encode/httpx/pull/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.