summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/unix_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-03 22:11:52 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-03 22:11:52 (GMT)
commit223a624158254e2c907116a756f6ffe63c49fb7a (patch)
treec777076d19ecb165b487e1e6b0fd2b95d71b37b2 /Lib/asyncio/unix_events.py
parentb9b965f6dd5be211a9ce047ac00070e51bc9b7a8 (diff)
downloadcpython-223a624158254e2c907116a756f6ffe63c49fb7a.zip
cpython-223a624158254e2c907116a756f6ffe63c49fb7a.tar.gz
cpython-223a624158254e2c907116a756f6ffe63c49fb7a.tar.bz2
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.
Diffstat (limited to 'Lib/asyncio/unix_events.py')
-rw-r--r--Lib/asyncio/unix_events.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 1fbdd31..230fbc3 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -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(