From e0460f8518be5ea41855cffdbddea94521e7dcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 12 Apr 2016 15:21:37 +0200 Subject: [PATCH] Don't crash when Algolia is unavailable, when updating user. --- pillar/application/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pillar/application/__init__.py b/pillar/application/__init__.py index 24a84bfd..061c96db 100644 --- a/pillar/application/__init__.py +++ b/pillar/application/__init__.py @@ -371,7 +371,15 @@ def post_GET_user(request, payload): def after_replacing_user(item, original): """Push an update to the Algolia index when a user item is updated""" - algolia_index_user_save(item) + + from algoliasearch.client import AlgoliaException + + try: + algolia_index_user_save(item) + except AlgoliaException as ex: + log.warning('Unable to push user info to Algolia for user "%s", id=%s; %s', + item.get('username'), item.get('_id'), ex) + app.on_post_GET_users += post_GET_user app.on_replace_users += after_replacing_user