mirror of https://github.com/python/cpython
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
This commit is contained in:
parent
3ef769fcd3
commit
0eba7c3913
|
@ -150,9 +150,14 @@ class TestSocketWrapper:
|
||||||
server_hostname=server_hostname,
|
server_hostname=server_hostname,
|
||||||
do_handshake_on_connect=False)
|
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
|
self.__sock = ssl_sock
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
|
|
@ -604,6 +604,8 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
|
||||||
server_side=True)
|
server_side=True)
|
||||||
except ssl.SSLError:
|
except ssl.SSLError:
|
||||||
pass
|
pass
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
|
@ -640,6 +642,7 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
|
||||||
except ssl.SSLError:
|
except ssl.SSLError:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
orig_sock.close()
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
async def client(addr):
|
async def client(addr):
|
||||||
|
@ -653,6 +656,8 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
|
||||||
writer.write(b'B')
|
writer.write(b'B')
|
||||||
with self.assertRaises(ssl.SSLError):
|
with self.assertRaises(ssl.SSLError):
|
||||||
await reader.readline()
|
await reader.readline()
|
||||||
|
|
||||||
|
writer.close()
|
||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
||||||
with self.tcp_server(server,
|
with self.tcp_server(server,
|
||||||
|
|
Loading…
Reference in New Issue