'Returns a list of Tasks leased for a certain time.
Args:
queue: The queue to query from.
lease_seconds: The tasks will be leased for this long.
limit: Number of values to fetch.
Returns:
A list of GrrMessage() objects leased.'

def QueryAndOwn(self, queue, lease_seconds=10, limit=1):

    user = ''
    if self.token:
        user = self.token.username
    try:
        lock = self.data_store.LockRetryWrapper(queue, lease_time=lease_seconds, token=self.token)
        return self._QueryAndOwn(lock.subject, lease_seconds=lease_seconds, limit=limit, user=user)
    except data_store.DBSubjectLockError:
        return []
    except data_store.Error as e:
        logging.warning('Datastore    exception:    %s', e)
        return []
