From ab3900e479199c2c74d26f3393f5485bd93d21bb Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Tue, 1 Mar 2011 15:31:43 +0100 Subject: [PATCH] Remove unneeded workaround for Darwin There is a clumsy workaround for Darwin that chunks reads into 8kb blocks to avoid huge memory allocations. First, this fix should not only be required but on FreeBSD2.6 too (see http://bugs.python.org/issue3531). Second, decent python versions (I checked 2.6) already chunk in the SSL case anyway, so there is no need to do that again. Remove that level of indirection. http://evanjones.ca/python-memory.html claims that this problem has been fixed since python 2.5, so we might consider removing the workaround completely even for the non-SSL case. Increase the chunk size on Mac from 8kb to 64kb. Even Macs should be able to take that amount of memory usage nowadays. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/imapserver.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 2a9f247..fa56af7 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -60,37 +60,23 @@ class UsefulIMAPMixIn: imaplibutil.new_mesg(self, s, secs) class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): - # This is a hack around Darwin's implementation of realloc() (which # Python uses inside the socket code). On Darwin, we split the - # message into 100k chunks, which should be small enough - smaller - # might start seriously hurting performance ... + # message into small chunks. + # see http://bugs.python.org/issue3531 def read(self, size): if (system() == 'Darwin') and (size>0) : read = 0 io = StringIO() while read < size: - data = imaplib.IMAP4.read (self, min(size-read,8192)) + data = imaplib.IMAP4.read (self, min(size-read, 65536)) read += len(data) io.write(data) return io.getvalue() else: return imaplib.IMAP4.read (self, size) -class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): - # This is the same hack as above, to be used in the case of an SSL - # connexion. - def read(self, size): - if (system() == 'Darwin') and (size>0) : - read = 0 - io = StringIO() - while read < size: - data = imaplibutil.WrappedIMAP4_SSL.read (self, min(size-read,8192)) - read += len(data) - io.write(data) - return io.getvalue() - else: - return imaplibutil.WrappedIMAP4_SSL.read (self,size) +class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass