From: Charles Connell Date: Mon, 27 Jan 2014 19:18:53 +0000 (-0500) Subject: Change how indexden exceptions are handled #281 X-Git-Tag: release-20150131~197 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9b8fd07613313a6f6ad2c97c21a1c03db768c970;p=oweals%2Fkarmaworld.git Change how indexden exceptions are handled #281 --- 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)