Issue #21119: asyncio now closes sockets on errors

Fix ResourceWarning: create_connection(), create_datagram_endpoint() and
create_unix_server() methods of event loop now close the newly created socket
on error.
This commit is contained in:
Victor Stinner 2014-06-04 00:11:52 +02:00
parent b9b965f6dd
commit 223a624158
4 changed files with 50 additions and 0 deletions

View file

@ -223,6 +223,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
raise OSError(errno.EADDRINUSE, msg) from None
else:
raise
except:
sock.close()
raise
else:
if sock is None:
raise ValueError(