gh-156400: Close the socket or pipe when transport creation fails in asyncio datagram/pipe endpoints - #156401
Conversation
…ls in asyncio datagram/pipe endpoints
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
On the proactor, _make_*_transport() takes ownership of the socket/pipe and starts I/O before it can raise, so closing it in connect_*()/create_*() double-manages it (broke test_windows_events). Close only when protocol_factory() raises, before any transport exists.
|
Thanks — fixed. The Windows failure was I've narrowed all three methods to close the socket/pipe only when |
create_datagram_endpoint(),connect_read_pipe()andconnect_write_pipe()create or take ownership of a socket/pipe and then runprotocol_factory()and transport creation. The only cleanup (except: transport.close()) coversawait waiter, so ifprotocol_factory()or_make_*_transport()raises the resource is never closed and leaks until garbage collection.Close the socket/pipe on that path, matching the
create_connection()fix in gh-153133. The added regression tests fail without the fix and pass with it; the fulltest_asynciosuite passes.