gh-155305: Preserve user-provided sockets on transport errors - #155341
gh-155305: Preserve user-provided sockets on transport errors#155341RealBhupesh wants to merge 2 commits into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68b960e9b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not sock_was_provided: | ||
| sock.close() |
There was a problem hiding this comment.
Restore caller sockets' blocking mode on failure
When a caller supplies a blocking socket and protocol_factory() or transport construction raises, this branch now leaves the socket open even though _create_connection_transport() has already changed it to nonblocking at line 1226 (and create_unix_connection() does so before calling this helper). Because no transport was created and ownership remains with the caller, subsequent ordinary socket operations can unexpectedly raise BlockingIOError; preserve and restore the socket's original timeout/blocking state on this failure path.
Useful? React with 👍 / 👎.
Fixes #155305.
Summary:
Tests:
asyncio.loop.create_connectioncloses user-provided socket on transport creation failure (Regression in 3.14.7) #155305