Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions test/asynchronous/test_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ class TestLB(AsyncIntegrationTest):
RUN_ON_LOAD_BALANCER = True

async def test_connections_are_only_returned_once(self):
if "PyPy" in sys.version:
# Tracked in PYTHON-3011
self.skipTest("Test is flaky on PyPy")
pool = await async_get_pool(self.client)
n_conns = len(pool.conns)
await self.db.test.find_one({})
# On PyPy it can take a few rounds to collect the cursor.
for _ in range(3):
gc.collect()
self.assertEqual(len(pool.conns), n_conns)
await (await self.db.test.aggregate([{"$limit": 1}])).to_list()
# On PyPy it can take a few rounds to collect the cursor.
for _ in range(3):
gc.collect()
self.assertEqual(len(pool.conns), n_conns)

@async_client_context.require_load_balancer
Expand Down
9 changes: 6 additions & 3 deletions test/test_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ class TestLB(IntegrationTest):
RUN_ON_LOAD_BALANCER = True

def test_connections_are_only_returned_once(self):
if "PyPy" in sys.version:
# Tracked in PYTHON-3011
self.skipTest("Test is flaky on PyPy")
pool = get_pool(self.client)
n_conns = len(pool.conns)
self.db.test.find_one({})
# On PyPy it can take a few rounds to collect the cursor.
for _ in range(3):
gc.collect()
self.assertEqual(len(pool.conns), n_conns)
(self.db.test.aggregate([{"$limit": 1}])).to_list()
# On PyPy it can take a few rounds to collect the cursor.
for _ in range(3):
gc.collect()
self.assertEqual(len(pool.conns), n_conns)

@client_context.require_load_balancer
Expand Down
Loading