Yes. There are three possibilities:
- Do an unacknowledged insert:
collection.insert(documents, w=0)
. The call to insert() returns as soon as the data has been written to the socket's output buffer, and your code does not block awaiting acknowledgment from MongoDB. You'll get no error reporting to your application. More info about write concerns here and here. - Add batches of documents to a Queue, and in a separate thread pop from the queue and insert into MongoDB:
collection.insert(q.get())
. - Port your application to Tornado and Motor as James Mills suggested; this seems to require the most learning of the three and is probably overkill.