'Retry a DBSubjectLock until it succeeds.
Args:
subject: The subject which the lock applies to.
retrywrap_timeout: How long to wait before retrying the lock.
token: An ACL token.
retrywrap_max_timeout: The maximum time to wait for a retry until we
raise.
blocking: If False, raise on first lock failure.
lease_time: lock lease time in seconds.
Returns:
The DBSubjectLock object
Raises:
DBSubjectLockError: If the maximum retry count has been reached.'

def LockRetryWrapper(self, subject, retrywrap_timeout=1, token=None, retrywrap_max_timeout=10, blocking=True, lease_time=None):

    timeout = 0
    while (timeout < retrywrap_max_timeout):
        try:
            return self.DBSubjectLock(subject, token=token, lease_time=lease_time)
        except DBSubjectLockError:
            if (not blocking):
                raise
            stats.STATS.IncrementCounter('datastore_retries')
            time.sleep(retrywrap_timeout)
            timeout += retrywrap_timeout
    raise DBSubjectLockError('Retry    number    exceeded.')
