From 8a4f63baadf8f28209d5fab95383634e8c813948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Thu, 5 Dec 2013 09:16:24 -0300 Subject: Fix deadlock situation if adding a skipped mail fails --- src/leap/mx/mail_receiver.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/leap') diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py index c06754e..c90dda9 100644 --- a/src/leap/mx/mail_receiver.py +++ b/src/leap/mx/mail_receiver.py @@ -266,20 +266,29 @@ class MailReceiver(Service): defer.returnValue(None) self._processing_skipped = True - log.msg("Starting processing skipped mail...") - log.msg("-"*50) - - for directory, recursive in self._directories: - for root, dirs, files in os.walk(directory): - for fname in files: - fullpath = os.path.join(root, fname) - fpath = filepath.FilePath(fullpath) - yield self._step_process_mail_backend(fpath) - - if not recursive: - break + try: + log.msg("Starting processing skipped mail...") + log.msg("-"*50) + + for directory, recursive in self._directories: + for root, dirs, files in os.walk(directory): + for fname in files: + try: + fullpath = os.path.join(root, fname) + fpath = filepath.FilePath(fullpath) + yield self._step_process_mail_backend(fpath) + except Exception as e: + log.msg("Error processing skipped mail: %r" % \ + (fullpath,)) + log.err() + if not recursive: + break + except Exception as e: + log.msg("Error processing skipped mail") + log.err() + finally: + self._processing_skipped = False - self._processing_skipped = False log.msg("+"*50) log.msg("Done processing skipped mail") -- cgit v1.2.3