aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/functional.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-07 01:12:38 +0200
committerGitHub <noreply@github.com>2018-06-07 01:12:38 +0200
commit0eba7c39132614a5730cda6b340e18dfb2d30d14 (patch)
treefae32716d814f9eb9ecc140dfbd9f7b30f6a0922 /Lib/test/test_asyncio/functional.py
parent3ef769fcd378a7f1cda19c0dfec2e79613d79e48 (diff)
downloadcpython-0eba7c39132614a5730cda6b340e18dfb2d30d14.tar.gz
cpython-0eba7c39132614a5730cda6b340e18dfb2d30d14.zip
bpo-33789: test_asyncio: Fix ResourceWarning (GH-7460)
* Close sockets and streams to fix ResourceWarning warnings * Catch also OSError to hide a traceback on an expected handshake error
Diffstat (limited to 'Lib/test/test_asyncio/functional.py')
-rw-r--r--Lib/test/test_asyncio/functional.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/functional.py b/Lib/test/test_asyncio/functional.py
index fbec462c1db..386cfcdb981 100644
--- a/Lib/test/test_asyncio/functional.py
+++ b/Lib/test/test_asyncio/functional.py
@@ -150,9 +150,14 @@ class TestSocketWrapper:
server_hostname=server_hostname,
do_handshake_on_connect=False)
- ssl_sock.do_handshake()
+ try:
+ ssl_sock.do_handshake()
+ except:
+ ssl_sock.close()
+ raise
+ finally:
+ self.__sock.close()
- self.__sock.close()
self.__sock = ssl_sock
def __getattr__(self, name):