@@ -461,24 +461,21 @@ async def test_connection_pool_is_not_cleared(self):
461461 # Create a client that listens to CMAP events, with maxConnecting=100.
462462 client = await self .async_rs_or_single_client (maxConnecting = 100 , event_listeners = [listener ])
463463
464- # Use an admin client for test setup and teardown to enable and disable the ingress rate limiter.
465- admin_client = self .client
466- await admin_client .admin .command (
464+ # Enable the ingress rate limiter.
465+ await client .admin .command (
467466 "setParameter" , 1 , ingressConnectionEstablishmentRateLimiterEnabled = True
468467 )
469- await admin_client .admin .command (
470- "setParameter" , 1 , ingressConnectionEstablishmentRatePerSec = 20
471- )
472- await admin_client .admin .command (
468+ await client .admin .command ("setParameter" , 1 , ingressConnectionEstablishmentRatePerSec = 20 )
469+ await client .admin .command (
473470 "setParameter" , 1 , ingressConnectionEstablishmentBurstCapacitySecs = 1
474471 )
475- await admin_client .admin .command (
476- "setParameter" , 1 , ingressConnectionEstablishmentMaxQueueDepth = 1
477- )
472+ await client .admin .command ("setParameter" , 1 , ingressConnectionEstablishmentMaxQueueDepth = 1 )
478473
479474 # Disable the ingress rate limiter on teardown.
475+ # Sleep for 1 second before disabling to avoid the rate limiter.
480476 async def teardown ():
481- await admin_client .admin .command (
477+ await asyncio .sleep (1 )
478+ await client .admin .command (
482479 "setParameter" , 1 , ingressConnectionEstablishmentRateLimiterEnabled = False
483480 )
484481
@@ -495,15 +492,6 @@ async def target():
495492 except ConnectionFailure :
496493 pass
497494
498- # Warm the pool with 10 tasks so there are existing connections.
499- tasks = []
500- for _ in range (10 ):
501- tasks .append (ConcurrentRunner (target = target ))
502- for t in tasks :
503- await t .start ()
504- for t in tasks :
505- await t .join ()
506-
507495 # Run 100 parallel operations that contend for connections.
508496 tasks = []
509497 for _ in range (100 ):
0 commit comments