[PATCH] Re: Avoid Fatal error: Word too long from Cyrus IMAP servers by chunking fetch.

Nicolas Sebrecht nicolas.s-dev at laposte.net
Wed Jan 19 18:46:33 GMT 2011


On Wed, Jan 19, 2011 at 08:41:27AM -0500, Edward Z. Yang wrote:
> 
> Signed-off-by: Edward Z. Yang <ezyang at mit.edu>
> ---
>  offlineimap/folder/IMAP.py |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
> index 927c5f4..75bda51 100644
> --- a/offlineimap/folder/IMAP.py
> +++ b/offlineimap/folder/IMAP.py
> @@ -180,7 +180,13 @@ class IMAPFolder(BaseFolder):
>              # Now, get the flags and UIDs for these.
>              # We could conceivably get rid of maxmsgid and just say
>              # '1:*' here.
> -            response = imapobj.fetch(messagesToFetch, '(FLAGS UID)')[1]
> +            batchNum = 50

Where does that "50" come from?

> +            response = []
> +            queueOfMessagesToFetch = messagesToFetch.split(',')
> +            while queueOfMessagesToFetch:
> +                batch = queueOfMessagesToFetch[0:batchNum]
> +                queueOfMessagesToFetch = queueOfMessagesToFetch[batchNum:]
> +                response += imapobj.fetch(','.join(batch), '(FLAGS UID)')[1]
>          finally:
>              self.imapserver.releaseconnection(imapobj)
>          for messagestr in response:

I think a bit comment in the code would be nice.

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list