Bugs item #1441530, was opened at 2006-03-02 09:27
Message generated for change (Comment added) made by mcicogni
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1441530&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: taukki (taukki)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket read() can cause MemoryError in Windows
Initial Comment:
When a big mail (>10MB) is fetched MemoryError may
result (reproduced in Windows XP/2003, Python 2.41):
Traceback (most recent call last):
File "t5.py", line 9, in ?
data = f.read(26872159)
File "c:\python24\lib\socket.py", line 307, in read
data = self._sock.recv(recv_size)
MemoryError
The problem is not actually in imaplib (though it
requests the whole mail in one read), but probably in
combination of socket core code and the implementation
of read() function (he way it buffers the received data
in a list?). I can easily reproduce the problem e.g
with these snippets:
------------CLIENT----------------->
import socket
import time
s = socket.socket()
s.connect(("127.0.0.1", 8037))
f = s.makefile("r", 200000)
while 1:
data = f.read(26872159) # Using smaller value here
helps, 100000 seems to work forever...
#data = s.recv(26872159) # THIS WORKS OK
print len(data)
---------SERVER--------------------->
import SocketServer
import time
PORT = 8037
time.sleep(0.2)
s = "X" * 1823
class
TimeRequestHandler(SocketServer.StreamRequestHandler):
def handle(self):
for x in range(200000):
self.wfile.write(s)
print x
server = SocketServer.TCPServer(("", PORT),
TimeRequestHandler)
print "listening on port", PORT
server.serve_forever()
----------------------------------------------------------------------
Comment By: Mauro Cicognini (mcicogni)
Date: 2007-05-21 19:14
Message:
Logged In: YES
user_id=134511
Originator: NO
Consistently reproducible using Python 2.5.1 on Windows XP.
Another bug on the same subject was closed WONTFIX since it all appears to
be Microsoft's fault (although asking a socket directly for more than 10MB
of data at once is arguably unreasonable).
Since it appears that it's just Imaplib implementation to be somewhat
broken, we could possibly patch *that* to work around this problem.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1441530&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com