mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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:
parent
b9b965f6dd
commit
223a624158
4 changed files with 50 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue