Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import gevent.monkey
gevent.monkey.patch_all()
import time
import pymongo
connection = pymongo.Connection(use_greenlets=True)
def task():
collection = connection.autoref.all_cars
# Make cursor, and make sure it opens a socket
cursor = collection.find()
cursor.next()
# Supposedly return this socket to the pool
connection.end_request()
if __name__ == "__main__":
jobs = [gevent.spawn(task) for i in xrange(500)]
gevent.joinall(jobs)
@liushuaikobe

This comment has been minimized.

Copy link

commented Oct 21, 2013

I have read your discussion in Google online forum. Is this the correct usage of gevent with pymongo?
Or, Hopefully, I'm new to pymongo, do you have any other examples of the gevent with pymongo?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.