@@ -69,7 +69,7 @@ After connecting, we run the initiate command to get things started::
6969 ... {'_id': 1, 'host': 'localhost:27018'},
7070 ... {'_id': 2, 'host': 'localhost:27019'}]}
7171 >>> c.admin.command("replSetInitiate", config)
72- {'info': 'Config now saved locally. Should come online in about a minute.', ' ok': 1.0}
72+ {'ok': 1.0, ... }
7373
7474The three ``mongod `` servers we started earlier will now coordinate
7575and come online as a replica set.
@@ -85,13 +85,13 @@ one or more members of the set, along with the replica set name. Any of
8585the following connects to the replica set we just created::
8686
8787 >>> MongoClient('localhost', replicaset='foo')
88- MongoClient('localhost', 27017 )
88+ MongoClient(host=[ 'localhost:27017'], replicaset='foo', ... )
8989 >>> MongoClient('localhost:27018', replicaset='foo')
90- MongoClient('localhost', 27018 )
90+ MongoClient([ 'localhost:27018'], replicaset='foo', ... )
9191 >>> MongoClient('localhost', 27019, replicaset='foo')
92- MongoClient('localhost', 27019 )
92+ MongoClient([ 'localhost:27019'], replicaset='foo', ... )
9393 >>> MongoClient('mongodb://localhost:27017,localhost:27018/?replicaSet=foo')
94- MongoClient(['localhost:27017', 'localhost:27018'])
94+ MongoClient(['localhost:27017', 'localhost:27018'], replicaset='foo', ... )
9595
9696The addresses passed to :meth: `~pymongo.mongo_client.MongoClient ` are called
9797the *seeds *. As long as at least one of the seeds is online, MongoClient
@@ -103,13 +103,15 @@ address of a single mongod. Multihomed and round robin DNS addresses are
103103The :class: `~pymongo.mongo_client.MongoClient ` constructor is non-blocking:
104104the constructor returns immediately while the client connects to the replica
105105set using background threads. Note how, if you create a client and immediately
106- print its string representation, the client only prints the single host it
107- knows about. If you wait a moment, it discovers the whole replica set:
106+ print the string representation of its
107+ :attr: `~pymongo.mongo_client.MongoClient.nodes ` attribute, the list may be
108+ empty initially. If you wait a moment, MongoClient discovers the whole replica
109+ set::
108110
109111 >>> from time import sleep
110- >>> c = MongoClient(replicaset = ' foo' ); print c ; sleep(0.1 ); print c
111- MongoClient('localhost', 27017 )
112- MongoClient([ u'localhost:27019 ', u'localhost:27017 ', u'localhost:27018' ])
112+ >>> c = MongoClient(replicaset='foo'); print(c.nodes) ; sleep(0.1); print(c.nodes)
113+ frozenset([] )
114+ frozenset([( u'localhost', 27019), ( u'localhost', 27017), ( u'localhost', 27018) ])
113115
114116You need not wait for replica set discovery in your application, however.
115117If you need to do any operation with a MongoClient, such as a
0 commit comments