From ae6e10e6c47a43e65cb3491d17b746234a62d133 Mon Sep 17 00:00:00 2001 From: Samuel Lai Date: Tue, 4 Mar 2014 15:47:11 +1100 Subject: [PATCH] Fixed a bug where import_site will loop forever if a non-SolrError exception is encountered. --- python/src/stackdump/commands/import_site.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/src/stackdump/commands/import_site.py b/python/src/stackdump/commands/import_site.py index 6275075..ad46a2b 100644 --- a/python/src/stackdump/commands/import_site.py +++ b/python/src/stackdump/commands/import_site.py @@ -538,13 +538,17 @@ class PostContentHandler(xml.sax.ContentHandler): By default, they are committed immediately. Set the ``commit`` argument to False to disable this behaviour. + + This function will loop if a SolrError is encountered to allow the user + to retry the commit without having to start again from the beginning, + e.g. if the Solr instance stops responding. """ while True: try: self.solr.add(questions, commit=commit) break except SolrError, e: - print('An exception occurred while committing questions - ') + print('A Solr error occurred while committing questions - ') traceback.print_exc(file=sys.stdout) print('') while True: @@ -557,6 +561,8 @@ class PostContentHandler(xml.sax.ContentHandler): break else: raise + except: + raise def commit_all_questions(self): """