diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-31 14:33:42 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-31 14:37:38 +0200 |
commit | fd8d3cc1da5079c931a7ad897bff047509f27a40 (patch) | |
tree | 5a198babecf9f7ad5abc6d0b4cff3227eb2a38a4 /service/pixelated/adapter | |
parent | 97b50f5b886928c70edcbcea149ced10f7065f19 (diff) |
Ensure MailboxIndexerListener does not let exceptions escape.
- Issue #445
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/listeners/mailbox_indexer_listener.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py index 77a78f0e..8896d742 100644 --- a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py +++ b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py @@ -13,10 +13,13 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. - +import logging from twisted.internet import defer +logger = logging.getLogger(__name__) + + class MailboxIndexerListener(object): """ Listens for new mails, keeping the index updated """ @@ -38,13 +41,16 @@ class MailboxIndexerListener(object): @defer.inlineCallbacks def newMessages(self, exists, recent): - indexed_idents = set(self.SEARCH_ENGINE.search('tag:' + self.mailbox_name.lower(), all_mails=True)) - soledad_idents = yield self.mail_store.get_mailbox_mail_ids(self.mailbox_name) - soledad_idents = set(soledad_idents) + try: + indexed_idents = set(self.SEARCH_ENGINE.search('tag:' + self.mailbox_name.lower(), all_mails=True)) + soledad_idents = yield self.mail_store.get_mailbox_mail_ids(self.mailbox_name) + soledad_idents = set(soledad_idents) - missing_idents = soledad_idents.difference(indexed_idents) + missing_idents = soledad_idents.difference(indexed_idents) - self.SEARCH_ENGINE.index_mails((yield self.mail_store.get_mails(missing_idents))) + self.SEARCH_ENGINE.index_mails((yield self.mail_store.get_mails(missing_idents))) + except Exception, e: # this is a event handler, don't let exceptions escape + logger.error(e) def __eq__(self, other): return other and other.mailbox_name == self.mailbox_name |