summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_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/base_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/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 3d4a87a..1c7073c 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -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: