File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -999,6 +999,28 @@ def test_max_pool_size_with_end_request_only(self):
999
999
# Call end_request() but not start_request()
1000
1000
self ._test_max_pool_size (0 , 1 )
1001
1001
1002
+ def test_max_pool_size_with_connection_failure (self ):
1003
+ # The pool acquires its semaphore before attempting to connect; ensure
1004
+ # it releases the semaphore on connection failure.
1005
+ class TestPool (Pool ):
1006
+ def connect (self , pair ):
1007
+ raise socket .error ()
1008
+
1009
+ test_pool = TestPool (
1010
+ pair = ('example.com' , 27017 ),
1011
+ max_size = 1 ,
1012
+ net_timeout = 1 ,
1013
+ conn_timeout = 1 ,
1014
+ use_ssl = False ,
1015
+ wait_queue_timeout = 1 ,
1016
+ use_greenlets = self .use_greenlets )
1017
+
1018
+ # First call to get_socket fails; if pool doesn't release its semaphore
1019
+ # then the second call raises "ConnectionFailure: Timed out waiting for
1020
+ # socket from pool" instead of the socket.error.
1021
+ for i in range (2 ):
1022
+ self .assertRaises (socket .error , test_pool .get_socket )
1023
+
1002
1024
1003
1025
class SocketGetter (MongoThread ):
1004
1026
"""Utility for _TestMaxOpenSockets and _TestWaitQueueMultiple"""
You can’t perform that action at this time.
0 commit comments