@@ -1018,7 +1018,7 @@ def get_pool_with_wait_queue_timeout(self, wait_queue_timeout):
1018
1018
def test_wait_queue_timeout (self ):
1019
1019
wait_queue_timeout = 2 # Seconds
1020
1020
pool = self .get_pool_with_wait_queue_timeout (wait_queue_timeout )
1021
- pool .get_socket ()
1021
+ sock_info = pool .get_socket ()
1022
1022
start = time .time ()
1023
1023
self .assertRaises (ConnectionFailure , pool .get_socket )
1024
1024
duration = time .time () - start
@@ -1027,6 +1027,8 @@ def test_wait_queue_timeout(self):
1027
1027
"Waited %.2f seconds for a socket, expected %f" % (
1028
1028
duration , wait_queue_timeout ))
1029
1029
1030
+ sock_info .close ()
1031
+
1030
1032
def test_blocking (self ):
1031
1033
# Verify get_socket() with no wait_queue_timeout blocks forever.
1032
1034
pool = self .get_pool_with_wait_queue_timeout (None )
@@ -1046,6 +1048,7 @@ def test_blocking(self):
1046
1048
1047
1049
self .assertEqual (t .state , 'sock' )
1048
1050
self .assertEqual (t .sock , s1 )
1051
+ s1 .close ()
1049
1052
1050
1053
1051
1054
class _TestWaitQueueMultiple (_TestPoolingBase ):
@@ -1064,8 +1067,8 @@ def test_wait_queue_multiple(self):
1064
1067
pool = self .get_pool_with_wait_queue_multiple (3 )
1065
1068
1066
1069
# Reach max_size sockets.
1067
- pool .get_socket ()
1068
- pool .get_socket ()
1070
+ socket_info_0 = pool .get_socket ()
1071
+ socket_info_1 = pool .get_socket ()
1069
1072
1070
1073
# Reach max_size * wait_queue_multiple waiters.
1071
1074
threads = []
@@ -1079,6 +1082,8 @@ def test_wait_queue_multiple(self):
1079
1082
self .assertEqual (t .state , 'get_socket' )
1080
1083
1081
1084
self .assertRaises (ExceededMaxWaiters , pool .get_socket )
1085
+ socket_info_0 .close ()
1086
+ socket_info_1 .close ()
1082
1087
1083
1088
def test_wait_queue_multiple_unset (self ):
1084
1089
pool = self .get_pool_with_wait_queue_multiple (None )
@@ -1095,6 +1100,9 @@ def test_wait_queue_multiple_unset(self):
1095
1100
for t in threads :
1096
1101
self .assertEqual (t .state , 'get_socket' )
1097
1102
1103
+ for socket_info in socks :
1104
+ socket_info .close ()
1105
+
1098
1106
1099
1107
class _TestPoolSocketSharing (_TestPoolingBase ):
1100
1108
"""Directly test that two simultaneous operations don't share a socket. To
0 commit comments