From 5bcbac33d6b8283d4943d9346f354e6dbe669a55 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Tue, 7 Jul 2015 23:05:15 -0700 Subject: [PATCH] Add handling for situations in which the message was deleted in another thread before processing. --- django_mailbox/transports/imap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django_mailbox/transports/imap.py b/django_mailbox/transports/imap.py index cef3eb4..82f7530 100644 --- a/django_mailbox/transports/imap.py +++ b/django_mailbox/transports/imap.py @@ -103,7 +103,13 @@ class ImapTransport(EmailTransport): typ, msg_contents = self.server.uid('fetch', uid, '(RFC822)') if not msg_contents: continue - message = self.get_email_from_bytes(msg_contents[0][1]) + try: + message = self.get_email_from_bytes(msg_contents[0][1]) + except TypeError: + # This happens if another thread/process deletes the + # message between our generating the ID list and our + # processing it here. + continue if condition and not condition(message): continue