[PATCH] Avoid Fatal error: Word too long from Cyrus IMAP servers by chunking fetch.
Edward Z. Yang
ezyang at MIT.EDU
Wed Jan 19 13:41:27 GMT 2011
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
+ 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:
--
1.7.0.4
More information about the OfflineIMAP-project
mailing list