Skip to content

Instantly share code, notes, and snippets.

@edgarcosta
Created May 4, 2016 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgarcosta/96d33b7ee79b4b64ab1123d50c05da6b to your computer and use it in GitHub Desktop.
Save edgarcosta/96d33b7ee79b4b64ab1123d50c05da6b to your computer and use it in GitHub Desktop.
Python 2.7.10 (default, Apr 25 2016, 18:50:49)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymongo import *
>>> from time import sleep
>>> print version
2.8
>>> C = MongoClient("m0.lmfdb.xyz", replicaSet = "lmfdb0", read_preference = ReadPreference.SECONDARY)
>>> sleep(1)
>>> print C.host
warwick.lmfdb.xyz
>>> print C.is_primary
True
>>> print C.read_preference
2
>>> print C.secondary_acceptable_latency_ms
15
>>> sleep(30)
>>> print C.host
warwick.lmfdb.xyz
>>> print C.is_primary
True
>>> print C.read_preference
2
>>> print C.secondary_acceptable_latency_ms
15
>>> print C.primary
Database(MongoClient([u'm1.lmfdb.xyz:27017', u'warwick.lmfdb.xyz:37010', u'm0.lmfdb.xyz:27017']), u'primary')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment