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

@ -412,6 +412,10 @@ class BaseEventLoop(events.AbstractEventLoop):
if sock is not None:
sock.close()
exceptions.append(exc)
except:
if sock is not None:
sock.close()
raise
else:
break
else:
@ -512,6 +516,10 @@ class BaseEventLoop(events.AbstractEventLoop):
if sock is not None:
sock.close()
exceptions.append(exc)
except:
if sock is not None:
sock.close()
raise
else:
break
else: