Skip to content

Ensure mounted transports are closed even if main transport raises#1070

Open
mbeijen wants to merge 1 commit into
pydantic:mainfrom
mbeijen:mounted-transports-close-on-raise
Open

Ensure mounted transports are closed even if main transport raises#1070
mbeijen wants to merge 1 commit into
pydantic:mainfrom
mbeijen:mounted-transports-close-on-raise

Conversation

@mbeijen

@mbeijen mbeijen commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

If a client with proxy mounts fails to close the main transport (its close()/exit/aclose()/aexit raises), the mounted transports were never reached, leaking their connections. Wrap the main transport cleanup in try/finally so mounts are always closed regardless.

Ported from encode/httpx#3769.

Review in cubic

If a client with proxy mounts fails to close the main transport (its
close()/__exit__/aclose()/__aexit__ raises), the mounted transports
were never reached, leaking their connections. Wrap the main
transport cleanup in try/finally so mounts are always closed
regardless.

Ported from encode/httpx#3769.
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing mbeijen:mounted-transports-close-on-raise (d543093) with main (c4e73cf)

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.

mbeijen added a commit to mbeijen/httpx2 that referenced this pull request Jul 15, 2026

@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 3 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.

2 participants