Skip to content

Commit

Permalink
possible fix for halting and catching fire after ~10,000 messages
Browse files Browse the repository at this point in the history
i was seeing imap2maildir spinning and eating all available memory
after a few hours of operation.  after review, i suspect it is because:

in imaplib.IMAP4_SSL:
    def readline(self):
        line = []
        while 1:
            char = self.sslobj.read(1)
            line.append(char)
            if char == "\n": return ''.join(line)

in ssl.SSLSocket:
    def read(self, len=1024):
        try:
            return self._sslobj.read(len)
        except SSLError, x:
            if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                return ''
            else:
                raise

guess what suppress_ragged_eofs defaults to, win a prize!
  • Loading branch information
Ryan Tucker committed Aug 17, 2009
1 parent 230c682 commit 98d3b43
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions simpleimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ class SimpleImap(imaplib.IMAP4, __simplebase):
pass

class SimpleImapSSL(imaplib.IMAP4_SSL, __simplebase):
def readline(self):
"""Read line from remote. Overrides built-in method to fix
infinite loop problem when EOF occurs, since sslobj.read
returns '' on EOF."""
line = []
while 1:
self.sslobj.suppress_ragged_eofs = False
char = self.sslobj.read(1)
line.append(char)
if char == "\n": return ''.join(line)

def read(self, n):
if 'Windows' in platform.platform():
maxRead = 1000000
Expand Down

0 comments on commit 98d3b43

Please sign in to comment.