Skip to content

Commit 5eb13b2

Browse files
author
A. Jesse Jiryu Davis
committed
Avoid ResourceWarnings in Python 3.
1 parent edc2350 commit 5eb13b2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/test_pooling_base.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ def get_pool_with_wait_queue_timeout(self, wait_queue_timeout):
10181018
def test_wait_queue_timeout(self):
10191019
wait_queue_timeout = 2 # Seconds
10201020
pool = self.get_pool_with_wait_queue_timeout(wait_queue_timeout)
1021-
pool.get_socket()
1021+
sock_info = pool.get_socket()
10221022
start = time.time()
10231023
self.assertRaises(ConnectionFailure, pool.get_socket)
10241024
duration = time.time() - start
@@ -1027,6 +1027,8 @@ def test_wait_queue_timeout(self):
10271027
"Waited %.2f seconds for a socket, expected %f" % (
10281028
duration, wait_queue_timeout))
10291029

1030+
sock_info.close()
1031+
10301032
def test_blocking(self):
10311033
# Verify get_socket() with no wait_queue_timeout blocks forever.
10321034
pool = self.get_pool_with_wait_queue_timeout(None)
@@ -1046,6 +1048,7 @@ def test_blocking(self):
10461048

10471049
self.assertEqual(t.state, 'sock')
10481050
self.assertEqual(t.sock, s1)
1051+
s1.close()
10491052

10501053

10511054
class _TestWaitQueueMultiple(_TestPoolingBase):
@@ -1064,8 +1067,8 @@ def test_wait_queue_multiple(self):
10641067
pool = self.get_pool_with_wait_queue_multiple(3)
10651068

10661069
# 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()
10691072

10701073
# Reach max_size * wait_queue_multiple waiters.
10711074
threads = []
@@ -1079,6 +1082,8 @@ def test_wait_queue_multiple(self):
10791082
self.assertEqual(t.state, 'get_socket')
10801083

10811084
self.assertRaises(ExceededMaxWaiters, pool.get_socket)
1085+
socket_info_0.close()
1086+
socket_info_1.close()
10821087

10831088
def test_wait_queue_multiple_unset(self):
10841089
pool = self.get_pool_with_wait_queue_multiple(None)
@@ -1095,6 +1100,9 @@ def test_wait_queue_multiple_unset(self):
10951100
for t in threads:
10961101
self.assertEqual(t.state, 'get_socket')
10971102

1103+
for socket_info in socks:
1104+
socket_info.close()
1105+
10981106

10991107
class _TestPoolSocketSharing(_TestPoolingBase):
11001108
"""Directly test that two simultaneous operations don't share a socket. To

0 commit comments

Comments
 (0)