Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 170

Show
Ignore:
Timestamp:
09/22/07 14:54:55
Author:
fumanchu
Message:

ConnectionPool?.retry was an int equal to the number of times to retry the conn at 1 second intervals. It may now also be a list or tuple of retry wait times; for example, [0, 1, 10, 60] will try to connect, try again immediately, then try again after 1 second, 10 seconds, and then 60 seconds.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/conns.py

    r169 r170  
    6868        self.pool = Queue.Queue(size) 
    6969        self.retry = retry 
     70        if isinstance(self.retry, (list, tuple)): 
     71            self.iterations = self.retry 
     72        else: 
     73            self.iterations = [x + 1 for x in range(self.retry)] 
    7074     
    7175    def __call__(self): 
    7276        """Return a connection from the pool.""" 
    73         for i in xrange(self.retry)
     77        for i in self.iterations
    7478            try: 
    7579                conn = self.pool.get_nowait() 
     
    9094                return w 
    9195            except errors.OutOfConnectionsError: 
    92                 time.sleep(i + 1
     96                time.sleep(i
    9397                conn = None 
    9498        raise errors.OutOfConnectionsError()