Close client SSE iterators explicitly when supported

KL
2mo ago
+195-73

Extract client SSE iterator cleanup from #3511. Both HTTP transports explicitly close their outer event iterators when aclose() is supported, accepting generators, closable class-based iterators, and plain async iterators.

The compatibility regression runs on both AnyIO backends. This does not claim complete nested HTTPX2 cleanup: HTTPX2 #1212 remains the blocker for full-suite Trio enablement in #3511, not for this extraction's locked-dependency checks.

Validation

macOS, Python 3.14: ./scripts/test passes with 6,025 passed, 9 skipped, 1 xfailed, 100% line/branch coverage, and strict-no-cover passing. Ruff lint/format and Pyright pass.

Also validated independently on main: 5,975 passed with 100% coverage and strict-no-cover. The three changed test modules pass all 78 cases on Python 3.10.

Stack

Part 4 of 5, stacked on #3542. The final backend-enablement PR is #3511.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.