Skip to content

PYTHON-3142 Stop using $where in test_maxConnecting #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2022
Merged
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: 5 additions & 4 deletions test/test_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,14 @@ def test_checkout_more_than_max_pool_size(self):
def test_maxConnecting(self):
client = rs_or_single_client()
self.addCleanup(client.close)
self.client.test.test.insert_one({})
self.addCleanup(self.client.test.test.delete_many, {})
pool = get_pool(client)
docs = []

# Run 50 short running operations
def find_one():
docs.append(client.test.test.find_one({"$where": delay(0.001)}))
docs.append(client.test.test.find_one({}))

threads = [threading.Thread(target=find_one) for _ in range(50)]
for thread in threads:
Expand All @@ -394,9 +396,8 @@ def find_one():
self.assertEqual(len(docs), 50)
self.assertLessEqual(len(pool.sockets), 50)
# TLS and auth make connection establishment more expensive than
# the artificially delayed query which leads to more threads
# hitting maxConnecting. The end result is fewer total connections
# and better latency.
# the query which leads to more threads hitting maxConnecting.
# The end result is fewer total connections and better latency.
if client_context.tls and client_context.auth_enabled:
self.assertLessEqual(len(pool.sockets), 30)
else:
Expand Down