Skip to content

Conversation

ShaneHarvey
Copy link
Member

Apps should use the hello command instead:

doc = client.admin.command('hello')
max_bson_size = doc['maxBsonObjectSize']
max_message_size = doc['maxMessageSizeBytes']
max_write_batch_size = doc['maxWriteBatchSize']

I'll address the remaining configuration attributes (max_pool_size, min_pool_size, max_idle_time_ms, local_threshold_ms, server_selection_timeout, etc.) in a new PR.

…tch_size

Use the hello command instead:
doc = client.admin.command('hello')
max_bson_size = doc['maxBsonObjectSize']
max_message_size = doc['maxMessageSizeBytes']
max_write_batch_size = doc['maxWriteBatchSize']
@@ -173,6 +173,27 @@ can be changed to this::

names = client.list_database_names()

MongoClient.max_bson_size/max_message_size/max_write_batch_size are removed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain why we're removing them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Waiting for the tests to pass.

return [s for s in selection.server_descriptions
if (s.round_trip_time - fastest) <= threshold]

def apply_selector(self, selector, address=None, custom_selector=None):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor quality improvement. The method was already "public" I just added docs and refactored apply_local_threshold to be a method instead of an inline function.

@@ -937,16 +937,16 @@ def address(self):

.. versionadded:: 3.0
"""
topology_type = self._topology._description.topology_type
# Block until we discover the topology type.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a minor bug exposed by one of the test changes. The bug was that client.address on a connect=False client would not open the topology as the documentation suggests:

        If the client is not connected, this will block until a connection is
        established or raise ServerSelectionTimeoutError if no server is
        available.

This fix is to attempt server selection once before doing the topology_type/primary checks. I don't think it's worth backporting to v3.

@ShaneHarvey ShaneHarvey marked this pull request as ready for review October 28, 2021 23:11
@ShaneHarvey ShaneHarvey requested review from julianedwards and juliusgeo and removed request for julianedwards October 28, 2021 23:23
Copy link
Contributor

@juliusgeo juliusgeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ShaneHarvey
Copy link
Member Author

@behackett did you want to review this again?

@ShaneHarvey ShaneHarvey merged commit 8b2eb24 into mongodb:master Nov 1, 2021
@ShaneHarvey ShaneHarvey deleted the PYTHON-2164 branch November 3, 2021 21:50
juliusgeo pushed a commit to juliusgeo/mongo-python-driver that referenced this pull request Apr 5, 2022
…tch_size (mongodb#766)

Use the hello command instead:
doc = client.admin.command('hello')
max_bson_size = doc['maxBsonObjectSize']
max_message_size = doc['maxMessageSizeBytes']
max_write_batch_size = doc['maxWriteBatchSize']

Also add documentation for TopologyDescription.apply_selector.
juliusgeo pushed a commit to juliusgeo/mongo-python-driver that referenced this pull request Apr 7, 2022
…tch_size (mongodb#766)

Use the hello command instead:
doc = client.admin.command('hello')
max_bson_size = doc['maxBsonObjectSize']
max_message_size = doc['maxMessageSizeBytes']
max_write_batch_size = doc['maxWriteBatchSize']

Also add documentation for TopologyDescription.apply_selector.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants