Created
March 2, 2011 14:45
-
-
Save tedroden/851033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === blah.py ==== | |
import pymongo | |
print "Version", pymongo.version | |
servers = "mongodb://localhost:27017,localhost:27018,localhost:27019/?slaveok=true" | |
DBNAME = "my-db" | |
COLLECTION = "User" | |
con = pymongo.Connection(servers) | |
db = con[DBNAME] | |
collection = db[COLLECTION] | |
for x in collection.find(): | |
print x | |
# === the shell ==== | |
$ python blah.py | |
Version 1.9+ | |
Traceback (most recent call last): | |
File "blah.py", line 10, in <module> | |
for x in collection.find(): | |
File "/Library/Python/2.6/site-packages/pymongo/cursor.py", line 601, in next | |
if len(self.__data) or self._refresh(): | |
File "/Library/Python/2.6/site-packages/pymongo/cursor.py", line 564, in _refresh | |
self.__query_spec(), self.__fields)) | |
File "/Library/Python/2.6/site-packages/pymongo/cursor.py", line 533, in __send_message | |
self.__tz_aware) | |
File "/Library/Python/2.6/site-packages/pymongo/helpers.py", line 98, in _unpack_response | |
raise AutoReconnect("master has changed") | |
pymongo.errors.AutoReconnect: master has changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment