Skip to content

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

Open
bysiber wants to merge 1 commit intoencode:masterfrom
bysiber:fix/ensure-transport-cleanup-on-close
Open

Ensure mounted transports are closed even if main transport raises#3769
bysiber wants to merge 1 commit intoencode:masterfrom
bysiber:fix/ensure-transport-cleanup-on-close

Conversation

@bysiber
Copy link

@bysiber bysiber commented Feb 20, 2026

When closing a client with proxy mounts, if the main transport's close()/__exit__() raises an exception, the mounted proxy transports would never be cleaned up. This wraps transport cleanup in try/finally to ensure all transports are properly closed.

Affects Client.close(), Client.__exit__(), AsyncClient.aclose(), and AsyncClient.__aexit__().

When closing a client with proxy mounts, if the main transport's
close/exit raises an exception, the mounted transports would never
be cleaned up. This could lead to leaked connections.

Wrap the main transport cleanup in try/finally to ensure mounted
transports are always properly closed.
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

Comments