Browse Source

Email_Fetcher : Be sure to catch all connection error

Guénaël Muller 7 years ago
parent
commit
fc1c836101
1 changed files with 13 additions and 8 deletions
  1. 13 8
      tracim/tracim/lib/email_fetcher.py

+ 13 - 8
tracim/tracim/lib/email_fetcher.py View File

@@ -212,13 +212,18 @@ class MailFetcher(object):
212 212
     def run(self) -> None:
213 213
         while self._is_active:
214 214
             time.sleep(self.delay)
215
-            self._connect()
216
-            mails = self._fetch()
217
-            # TODO - G.M -  2017-11-22 retry sending unsended mail
218
-            # These mails are return by _notify_tracim, flag them with "unseen"
219
-            # or store them until new _notify_tracim call
220
-            self._notify_tracim(mails)
221
-            self._disconnect()
215
+            try:
216
+                self._connect()
217
+                mails = self._fetch()
218
+                # TODO - G.M -  2017-11-22 retry sending unsended mail
219
+                # These mails are return by _notify_tracim, flag them with "unseen"
220
+                # or store them until new _notify_tracim call
221
+                self._notify_tracim(mails)
222
+                self._disconnect()
223
+            except Exception as e:
224
+                # TODO - G.M - 2017-11-23 - Identify possible exceptions
225
+                log = 'IMAP error: {}'
226
+                logger.warning(self, log.format(e.__str__()))
222 227
 
223 228
     def stop(self) -> None:
224 229
         self._is_active = False
@@ -240,7 +245,7 @@ class MailFetcher(object):
240 245
             self._connection.login(self.user, self.password)
241 246
         except Exception as e:
242 247
             log = 'IMAP login error: {}'
243
-            logger.debug(self, log.format(e.__str__()))
248
+            logger.warning(self, log.format(e.__str__()))
244 249
 
245 250
     def _disconnect(self) -> None:
246 251
         if self._connection: