Selaa lähdekoodia

Email_Fetcher : Be sure to catch all connection error

Guénaël Muller 7 vuotta sitten
vanhempi
commit
fc1c836101
1 muutettua tiedostoa jossa 13 lisäystä ja 8 poistoa
  1. 13 8
      tracim/tracim/lib/email_fetcher.py

+ 13 - 8
tracim/tracim/lib/email_fetcher.py Näytä tiedosto

212
     def run(self) -> None:
212
     def run(self) -> None:
213
         while self._is_active:
213
         while self._is_active:
214
             time.sleep(self.delay)
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
     def stop(self) -> None:
228
     def stop(self) -> None:
224
         self._is_active = False
229
         self._is_active = False
240
             self._connection.login(self.user, self.password)
245
             self._connection.login(self.user, self.password)
241
         except Exception as e:
246
         except Exception as e:
242
             log = 'IMAP login error: {}'
247
             log = 'IMAP login error: {}'
243
-            logger.debug(self, log.format(e.__str__()))
248
+            logger.warning(self, log.format(e.__str__()))
244
 
249
 
245
     def _disconnect(self) -> None:
250
     def _disconnect(self) -> None:
246
         if self._connection:
251
         if self._connection: