@@ -124,7 +124,7 @@ def run_mongo_thread(self):
124124 self .state = 'get_socket'
125125
126126 # Pass 'checkout' so we can hold the socket.
127- with self .pool .get_socket ({}, 0 , 0 , checkout = True ) as sock :
127+ with self .pool .get_socket ({}, checkout = True ) as sock :
128128 self .sock = sock
129129
130130 self .state = 'sock'
@@ -189,10 +189,10 @@ def test_pool_reuses_open_socket(self):
189189 # Test Pool's _check_closed() method doesn't close a healthy socket.
190190 cx_pool = self .create_pool (max_pool_size = 10 )
191191 cx_pool ._check_interval_seconds = 0 # Always check.
192- with cx_pool .get_socket ({}, 0 , 0 ) as sock_info :
192+ with cx_pool .get_socket ({}) as sock_info :
193193 pass
194194
195- with cx_pool .get_socket ({}, 0 , 0 ) as new_sock_info :
195+ with cx_pool .get_socket ({}) as new_sock_info :
196196 self .assertEqual (sock_info , new_sock_info )
197197
198198 self .assertEqual (1 , len (cx_pool .sockets ))
@@ -201,11 +201,11 @@ def test_get_socket_and_exception(self):
201201 # get_socket() returns socket after a non-network error.
202202 cx_pool = self .create_pool (max_pool_size = 1 , wait_queue_timeout = 1 )
203203 with self .assertRaises (ZeroDivisionError ):
204- with cx_pool .get_socket ({}, 0 , 0 ) as sock_info :
204+ with cx_pool .get_socket ({}) as sock_info :
205205 1 / 0
206206
207207 # Socket was returned, not closed.
208- with cx_pool .get_socket ({}, 0 , 0 ) as new_sock_info :
208+ with cx_pool .get_socket ({}) as new_sock_info :
209209 self .assertEqual (sock_info , new_sock_info )
210210
211211 self .assertEqual (1 , len (cx_pool .sockets ))
@@ -214,7 +214,7 @@ def test_pool_removes_closed_socket(self):
214214 # Test that Pool removes explicitly closed socket.
215215 cx_pool = self .create_pool ()
216216
217- with cx_pool .get_socket ({}, 0 , 0 ) as sock_info :
217+ with cx_pool .get_socket ({}) as sock_info :
218218 # Use SocketInfo's API to close the socket.
219219 sock_info .close ()
220220
@@ -226,25 +226,25 @@ def test_pool_removes_dead_socket(self):
226226 cx_pool = self .create_pool (max_pool_size = 1 , wait_queue_timeout = 1 )
227227 cx_pool ._check_interval_seconds = 0 # Always check.
228228
229- with cx_pool .get_socket ({}, 0 , 0 ) as sock_info :
229+ with cx_pool .get_socket ({}) as sock_info :
230230 # Simulate a closed socket without telling the SocketInfo it's
231231 # closed.
232232 sock_info .sock .close ()
233233 self .assertTrue (socket_closed (sock_info .sock ))
234234
235- with cx_pool .get_socket ({}, 0 , 0 ) as new_sock_info :
235+ with cx_pool .get_socket ({}) as new_sock_info :
236236 self .assertEqual (0 , len (cx_pool .sockets ))
237237 self .assertNotEqual (sock_info , new_sock_info )
238238
239239 self .assertEqual (1 , len (cx_pool .sockets ))
240240
241241 # Semaphore was released.
242- with cx_pool .get_socket ({}, 0 , 0 ):
242+ with cx_pool .get_socket ({}):
243243 pass
244244
245245 def test_return_socket_after_reset (self ):
246246 pool = self .create_pool ()
247- with pool .get_socket ({}, 0 , 0 ) as sock :
247+ with pool .get_socket ({}) as sock :
248248 pool .reset ()
249249
250250 self .assertTrue (sock .closed )
@@ -258,20 +258,20 @@ def test_pool_check(self):
258258 wait_queue_timeout = 1 )
259259 cx_pool ._check_interval_seconds = 0 # Always check.
260260
261- with cx_pool .get_socket ({}, 0 , 0 ) as sock_info :
261+ with cx_pool .get_socket ({}) as sock_info :
262262 # Simulate a closed socket without telling the SocketInfo it's
263263 # closed.
264264 sock_info .sock .close ()
265265
266266 # Swap pool's address with a bad one.
267267 address , cx_pool .address = cx_pool .address , ('foo.com' , 1234 )
268268 with self .assertRaises (socket .error ):
269- with cx_pool .get_socket ({}, 0 , 0 ):
269+ with cx_pool .get_socket ({}):
270270 pass
271271
272272 # Back to normal, semaphore was correctly released.
273273 cx_pool .address = address
274- with cx_pool .get_socket ({}, 0 , 0 , checkout = True ):
274+ with cx_pool .get_socket ({}, checkout = True ):
275275 pass
276276
277277 def test_pool_with_fork (self ):
@@ -326,18 +326,18 @@ def loop(pipe):
326326 self .assertTrue (b_sock != c_sock )
327327
328328 # a_sock, created by parent process, is still in the pool
329- with get_pool (a ).get_socket ({}, 0 , 0 ) as d_sock :
329+ with get_pool (a ).get_socket ({}) as d_sock :
330330 self .assertEqual (a_sock , d_sock )
331331
332332 def test_wait_queue_timeout (self ):
333333 wait_queue_timeout = 2 # Seconds
334334 pool = self .create_pool (
335335 max_pool_size = 1 , wait_queue_timeout = wait_queue_timeout )
336336
337- with pool .get_socket ({}, 0 , 0 ) as sock_info :
337+ with pool .get_socket ({}) as sock_info :
338338 start = time .time ()
339339 with self .assertRaises (ConnectionFailure ):
340- with pool .get_socket ({}, 0 , 0 ):
340+ with pool .get_socket ({}):
341341 pass
342342
343343 duration = time .time () - start
@@ -353,7 +353,7 @@ def test_no_wait_queue_timeout(self):
353353 pool = self .create_pool (max_pool_size = 1 )
354354
355355 # Reach max_size.
356- with pool .get_socket ({}, 0 , 0 ) as s1 :
356+ with pool .get_socket ({}) as s1 :
357357 t = SocketGetter (self .c , pool )
358358 t .start ()
359359 while t .state != 'get_socket' :
@@ -375,8 +375,8 @@ def test_wait_queue_multiple(self):
375375 max_pool_size = 2 , wait_queue_multiple = wait_queue_multiple )
376376
377377 # Reach max_size sockets.
378- with pool .get_socket ({}, 0 , 0 ):
379- with pool .get_socket ({}, 0 , 0 ):
378+ with pool .get_socket ({}):
379+ with pool .get_socket ({}):
380380
381381 # Reach max_size * wait_queue_multiple waiters.
382382 threads = []
@@ -390,7 +390,7 @@ def test_wait_queue_multiple(self):
390390 self .assertEqual (t .state , 'get_socket' )
391391
392392 with self .assertRaises (ExceededMaxWaiters ):
393- with pool .get_socket ({}, 0 , 0 ):
393+ with pool .get_socket ({}):
394394 pass
395395
396396 def test_no_wait_queue_multiple (self ):
@@ -399,7 +399,7 @@ def test_no_wait_queue_multiple(self):
399399 socks = []
400400 for _ in range (2 ):
401401 # Pass 'checkout' so we can hold the socket.
402- with pool .get_socket ({}, 0 , 0 , checkout = True ) as sock :
402+ with pool .get_socket ({}, checkout = True ) as sock :
403403 socks .append (sock )
404404
405405 threads = []
@@ -498,7 +498,7 @@ def test_max_pool_size_with_connection_failure(self):
498498 # socket from pool" instead of the socket.error.
499499 for i in range (2 ):
500500 with self .assertRaises (socket .error ):
501- with test_pool .get_socket ({}, 0 , 0 , checkout = True ):
501+ with test_pool .get_socket ({}, checkout = True ):
502502 pass
503503
504504
0 commit comments