Skip to content

Allow retrying failed pool stream closes - #1350

Closed
Jacob-Met wants to merge 1 commit into
pydantic:mainfrom
Jacob-Met:fix/httpcore2-pool-close-retry-1328
Closed

Jacob-Met wants to merge 1 commit into
pydantic:mainfrom
Jacob-Met:fix/httpcore2-pool-close-retry-1328

Conversation

@Jacob-Met

@Jacob-Met Jacob-Met commented Nov 16, 2026 •

Copy link
Copy Markdown

Fixes #1328.

PoolByteStream.aclose() marked itself closed before closing its inner stream. An ordinary close exception then made every retry a no-op, leaving the associated pool request registered. The sync path had the same failure.

Roll back _closed only when the inner close raises, preserving its successful-close idempotence. Regression tests cover a failing first close, successful retry, pool-slot release, and a no-op third close for asyncio, trio and sync.

Verified with scripts/check, scripts/test (2,132 passed, 100% coverage), and a fresh installed httpcore2 wheel exercised with the reported reproduction on Python 3.15.

View guided diff

@veria-ai

veria-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@codspeed

codspeed Bot commented Nov 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing Jacob-Met:fix/httpcore2-pool-close-retry-1328 (40e4f2d) with main (3d83a70)

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 4 files

View guided diff | Re-trigger cubic

@Kludex Kludex closed this Nov 16, 2026
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.

A failed close in PoolByteStream latches _closed and keeps the pool slot

2 participants