changeset 9:896bea4f61a0

try to deal with timeout on connect.
author casties
date Wed, 19 Jun 2013 17:16:05 +0200
parents a8f16569d1a6
children f7fe88804cb8
files zopeSolr.py
diffstat 1 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/zopeSolr.py	Tue May 28 16:18:59 2013 +0200
+++ b/zopeSolr.py	Wed Jun 19 17:16:05 2013 +0200
@@ -15,6 +15,7 @@
 import xml.etree.ElementTree as ET
 import json
 import random
+import logging
    
 #Worte die nicht in der Termliste angezeigt werden sollen #TODO: make this configurable
 
@@ -67,7 +68,11 @@
         
            
         if not getattr(self,'_v_solr_',None):
-            self.connect()
+            try:
+                self.connect()
+            except Exception, e:
+                logging.error("Error connecting to Solr: %s"%e)
+                return []
        
        #http://localhost:8983/solr/mpiwgSources/select/?q=*:*&sort=random_12xs34%20desc&rows=1&facet=false
 
@@ -183,9 +188,11 @@
         #    fls[fl]={}
         
         if not getattr(self,'_v_solr_',None):
-            self.connect()
-        
-        
+            try:
+                self.connect()
+            except Exception, e:
+                logging.error("Error connecting to Solr: %s"%e)
+                return res
     
         for x in range(begin,end,increment):
             query={}
@@ -309,9 +316,11 @@
         
         #teste verbindung zu solr
         if not getattr(self,'_v_solr_',None):
-            self.connect()
-        
-        
+            try:
+                self.connect()
+            except Exception, e:
+                logging.error("Error connecting to Solr: %s"%e)
+                return []
         
         solrQuery = solrQuery.decode('utf-8')