-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
MongoClient.address and how it's used internally by MongoClient has a number of problems. First, client.address does not always block for the primary to be discovered. For example:
>>> client = MongoClient(connect=False) >>> client.topology_description <TopologyDescription id: 617af87d67f12b13103312e5, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None>]> >>> client.address >>> client.topology_description <TopologyDescription id: 617af87d67f12b13103312e5, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None>]> >>> client.admin.command('hello')['me'] 'localhost:27017' >>> client.topology_description <TopologyDescription id: 617af87d67f12b13103312e5, topology_type: ReplicaSetWithPrimary, servers: [<ServerDescription ('localhost', 27017) server_type: RSPrimary, rtt: 0.0008715150179341435>]> >>> client.address ('localhost', 27017)
Second, client.address is used for comparison and hashing in client._eq_ and client._hash_ which does not make sense since 1) client.address can block and 2) client.address can change.
We should change client._eq_ and client._hash_ to use something immutable like the connection string or list of seeds.
- related to
-
PYTHON-2164 Rethink MongoClient read only configuration attributes
- Closed