Changeset 4496 for MILK


Ignore:
Timestamp:
27/11/08 09:39:03 (11 years ago)
Author:
cbyrom
Message:

Add retry facility for running eXist searches with - to cope with the spurious OutOfBounds? exceptions that are sometimes encountered.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/listatom.py

    r4486 r4496  
    55 @author: C Byrom, Tessella Sep 2008 
    66''' 
    7 import logging 
     7import logging, xmlrpclib 
    88from paste.request import parse_querystring 
    99from xml.parsers.expat import ExpatError 
     
    156156        dr = DocumentRetrieve(self.cf.get('NDG_EXIST','local'), 
    157157                              pwfile=self.cf.get('NDG_EXIST','passwordFile')) 
    158      
    159         results = dr.search(term, 
     158         
     159        # NB, for some reason, this sometimes results in a spurious  
     160        # 'java.lang.IndexOutOfBoundsException' - retry a couple of times, if so 
     161        attempt = 0 
     162        results = None 
     163        while not results: 
     164            try: 
     165                results = dr.search(term, 
    160166                            start=1, 
    161167                            howmany=10000, # NB, we want to get back everything! 
     
    163169                            providerID = providerID,  
    164170                            atomTypeID = atomTypeID) 
     171            except xmlrpclib.Fault, e: 
     172                logging.info("Error caught whilst calling eXist: %s" %e.faultString) 
     173                attempt += 1 
     174                if attempt < 3: 
     175                    logging.info("- retrying eXist call") 
     176                else: 
     177                    raise e 
    165178 
    166179        logging.info("Search completed") 
Note: See TracChangeset for help on using the changeset viewer.