julienfr112
julienfr112

Reputation: 2137

Is it possible to "fire and forget" a request with pymongo

For example in a tornado application, i would like to remove an element, but i don't care about the result of the remove.

Is it possible to use pymongo that way :

import pymongo
db=pymongo.connection()['mydb']
class assassin(RequestHandler):
    get(self):
        id=self.get_argument('id')
        self.write('delete send')
        db['personne'].remove({'_id':ObjectId(id)}

Upvotes: 0

Views: 374

Answers (1)

JohnnyHK
JohnnyHK

Reputation: 312055

As Sammaye alludes to, you can disable all write acknowledgement via the "write concern" option to remove which makes it fire-and-forget:

db['personne'].remove({'_id':ObjectId(id)}, w=0)

Upvotes: 2

Related Questions