-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental: expose the cursor in find() queries #57
Comments
Seems interesting, but how does the cleanup work in case something fails (e.g. exception) and you have the cursor no longer accessible? |
That's a good question. It is basically the same as running one query per loop. If an exception occurs in the middle, it would be like failing in the middle of a generator. Mongo itself will expire a cursor after an amount of time (cursor expiration) |
@trenton42: Why not send a pull request? I'de like to see this. |
@psi29a Pull request submitted! |
I have been thinking for quite a while about being able to run queries without loading the entire result set into memory. Here's what I came up with (view the Changes):
collection.find_with_cursor returns a deferred which results in a tuple: (docs, deferred). If there are no more documents remaining in the current query, a deferred will be returned which results in this tuple: ([], None)
For example:
I have already implemented this (here), but let me know what you think, or if there are any improvements that could be made on this, then I will send over a pull request
The text was updated successfully, but these errors were encountered: