From f51eabeae841f7312d0f2f23db2ca6e7205987d8 Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Fri, 16 Jul 2010 07:50:08 +0000 Subject: [PATCH] Fixes issue #141 - infinite loop for IMAP after certain return codes. Thanks to Walter Doekes for the patch. --- management/commands/get_email.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/management/commands/get_email.py b/management/commands/get_email.py index c0a72ec9..2b7cf7bf 100644 --- a/management/commands/get_email.py +++ b/management/commands/get_email.py @@ -112,11 +112,10 @@ def process_queue(q, quiet=False): server.login(q.email_box_user, q.email_box_pass) server.select(q.email_box_imap_folder) - while True: - status, data = server.search(None, 'NOT', 'DELETED') + + status, data = server.search(None, 'NOT', 'DELETED') + if data: msgnums = data[0].split() - if not msgnums: - break for num in msgnums: status, data = server.fetch(num, '(RFC822)') ticket = ticket_from_message(message=data[0][1], queue=q, quiet=quiet)