You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.
So I finally got time to look at using tailable cursor with mongodb. I've been playing with asyncmongo a bit, planning on using it to read/write within requests. It however doesn't really work with tailable cursors because there needs to be a real cursor to iterate on, and asyncmongo doesn't seem to return those? I played around with the Cursor class, and it doesn't have support for attributes like alive and methods like next.
Here's how I set up a nonblocking tailable cursor implementation with Tornado and pymongo. Maybe something like this could be included in an asyncmongo at some point?
notes: mycoll needs to be a capped collection. The purpose is to be able to just stream updates to each app server as they happen, rather than repeatedly poll the database. The count is just in case messages are coming in too fast, grabbing x at a time (100 in this case, which is probably way too low) and then freeing the loop up seems to be a way to go.
Thinking about this, it might actually be better performance to just poll, and I think I might go in that direction after all. But I didn't want to just throw the code away if it's something you might be able to use and others might have a use for.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
So I finally got time to look at using tailable cursor with mongodb. I've been playing with asyncmongo a bit, planning on using it to read/write within requests. It however doesn't really work with tailable cursors because there needs to be a real cursor to iterate on, and asyncmongo doesn't seem to return those? I played around with the Cursor class, and it doesn't have support for attributes like alive and methods like next.
Here's how I set up a nonblocking tailable cursor implementation with Tornado and pymongo. Maybe something like this could be included in an asyncmongo at some point?
notes: mycoll needs to be a capped collection. The purpose is to be able to just stream updates to each app server as they happen, rather than repeatedly poll the database. The count is just in case messages are coming in too fast, grabbing x at a time (100 in this case, which is probably way too low) and then freeing the loop up seems to be a way to go.
Thinking about this, it might actually be better performance to just poll, and I think I might go in that direction after all. But I didn't want to just throw the code away if it's something you might be able to use and others might have a use for.
The text was updated successfully, but these errors were encountered: