import time from bson import Binary from pymongo import MongoClient, DESCENDING
bucket = MongoClient('127.0.0.1', 27017)['test']['foo'] bucket.drop() bucket.update({'timestamp': 0}, {'$addToSet': {'_exists_caps': 'cap15'}}, upsert=True, safe=True, j=True, w=1, wtimeout=10) bucket.create_index([('timestamp', DESCENDING)], unique=True) while True: timestamp = str(int(1000000 * time.time())) bucket.update({'timestamp': timestamp}, {'$addToSet': {'_exists_caps': 'cap15'}}, upsert=True, safe=True, w=1, wtimeout=10)
Traceback (most recent call last): File "test_mongo_update.py", line 13, in <module> bucket.update({'timestamp': timestamp}, {'$addToSet': {'_exists_caps': 'cap15'}}, upsert=True, safe=True, w=1, wtimeout=10) File "build/bdist.linux-x86_64/egg/pymongo/collection.py", line 552, in update File "build/bdist.linux-x86_64/egg/pymongo/helpers.py", line 202, in _check_write_command_responsepymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: test.foo index: timestamp_-1 dup key: { : "1439372554049783" }
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-dev.
For more options, visit https://groups.google.com/d/optout.