-
Notifications
You must be signed in to change notification settings - Fork 1.1k
MemoryError while retrieving large cursors #142
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
Conversation
Stack: for user in all_users: File "C:\Python27\lib\site-packages\pymongo\cursor.py", line 778, in next if len(self.__data) or self._refresh(): File "C:\Python27\lib\site-packages\pymongo\cursor.py", line 742, in _refresh limit, self.__id)) File "C:\Python27\lib\site-packages\pymongo\cursor.py", line 666, in __send_message **kwargs) File "C:\Python27\lib\site-packages\pymongo\connection.py", line 907, in _send_message_with_response return self.__send_and_receive(message, sock_info) File "C:\Python27\lib\site-packages\pymongo\connection.py", line 885, in __send_and_receive return self.__receive_message_on_socket(1, request_id, sock_info) File "C:\Python27\lib\site-packages\pymongo\connection.py", line 877, in __receive_message_on_socket return self.__receive_data_on_socket(length - 16, sock_info) File "C:\Python27\lib\site-packages\pymongo\connection.py", line 858, in __receive_data_on_socket chunk = sock_info.sock.recv(length) MemoryError
Just tried the same code to run on Ubuntu, python 2.6.5, exception doesn't happen. |
Related: #132 |
@TomasB just to clarify you get this memory error on Windows python 2.7.2 and Ubuntu python 2.7.3. |
@rozza, the tests I ran: In all these cases I was connecting to the same db, which is running on ubuntu mongo v2.0.7. |
When I want to loop through a whole collection, it fails at 101 attempt to retrieve document.
|
To get the results you are expecting for count you should use Cursor.count and pass with_limit_and_skip=True. See the docs here: http://api.mongodb.org/python/current/api/pymongo/cursor.html#pymongo.cursor.Cursor.count We're looking at the memory issues. |
@behackett thanks for the tip |
@TomasB can you open a bug report at jira.mongodb.org in the "Python Driver" project, please? We need to work with you a little more to understand what the underlying problem is. |
Sure, I'll do, but the earliest is going to be coming Wednesday. |
@TomasB what version of Windows are you using? Windows 7, XP, 2000? How much RAM is installed on the Windows machine? Is it a 32- or 64-bit machine? |
OS Name Microsoft Windows 7 Professional 32 bit |
Hmm.. looks like io.BytesIO has some space for improvement: http://mail.python.org/pipermail/python-dev/2012-July/120983.html |
io.BytesIO wouldn't have worked either way since we support back to CPython 2.4 (and Jython just recently added an io module). I think we are going to use PyMongo's implementation from before 2.2, as I mentioned in PYTHON-413. |
This is the issue we experience on windows machines:
Python version v2.7.2
Mongo v2.0.7 (running on ubuntu)
At this point I am not even convinced that this is pymongo's issue, and not python's, but the change seems to fix the this without any other bad side affects.
Please do not hesitate to request for more info, I'm quite eager to have it resolved in driver's mainstream code.