summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-12-05 09:16:24 -0300
committerTomás Touceda <chiiph@leap.se>2013-12-05 09:16:24 -0300
commit8a4f63baadf8f28209d5fab95383634e8c813948 (patch)
tree81a7c0a65bd502c48e1943de750b59cd2197dbd7
parent338252c1c123403687287b503b154db212b16b92 (diff)
Fix deadlock situation if adding a skipped mail fails
-rw-r--r--src/leap/mx/mail_receiver.py35
1 files changed, 22 insertions, 13 deletions
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")