This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taukki
Recipients
Date 2006-03-02.08:27:59
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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()



History
Date User Action Args
2007-08-23 14:38:09adminlinkissue1441530 messages
2007-08-23 14:38:09admincreate