From 9b8fd07613313a6f6ad2c97c21a1c03db768c970 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Mon, 27 Jan 2014 14:18:53 -0500 Subject: [PATCH] Change how indexden exceptions are handled #281 --- karmaworld/apps/notes/models.py | 11 ++++++++--- karmaworld/apps/notes/search.py | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index eec394f..23007cf 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -362,10 +362,12 @@ def note_save_receiver(sender, **kwargs): return note = kwargs['instance'] + if kwargs['created']: + update_note_counts(note) + try: index = SearchIndex() if kwargs['created']: - update_note_counts(note) index.add_note(note) else: index.update_note(note, note.old_instance) @@ -384,8 +386,11 @@ def note_delete_receiver(sender, **kwargs): update_note_counts(kwargs['instance']) # Remove document from search index - index = SearchIndex() - index.remove_note(note) + try: + index = SearchIndex() + index.remove_note(note) + except Exception: + logger.error("Error with IndexDen:\n" + traceback.format_exc()) if note.user: GenericKarmaEvent.create_event(note.user, note.name, GenericKarmaEvent.NOTE_DELETED) diff --git a/karmaworld/apps/notes/search.py b/karmaworld/apps/notes/search.py index 3ae352d..629b73c 100644 --- a/karmaworld/apps/notes/search.py +++ b/karmaworld/apps/notes/search.py @@ -64,6 +64,7 @@ class SearchIndex(object): self.api_client = itc.ApiClient(secret.PRIVATE_URL) if not self.api_client.get_index(self.index_name).exists(): + time.sleep(5) self.api_client.create_index(self.index_name, {'public_search': False}) self.index = self.api_client.get_index(self.index_name) -- 2.25.1