Retrieves tasks from a queue without leasing them.

    This is good for a read only snapshot of the tasks.

    Args:
      queue: The task queue that this task belongs to, usually client.Queue()
        where client is the ClientURN object you want to schedule msgs on.
      limit: Number of values to fetch.

    Returns:
      A list of Task() objects.

def QueueQueryTasks(self, queue, limit=1):
    """Retrieves tasks from a queue without leasing them.

    This is good for a read only snapshot of the tasks.

    Args:
      queue: The task queue that this task belongs to, usually client.Queue()
        where client is the ClientURN object you want to schedule msgs on.
      limit: Number of values to fetch.

    Returns:
      A list of Task() objects.
    """
    prefix = DataStore.QUEUE_TASK_PREDICATE_PREFIX
    all_tasks = []

    for _, serialized, ts in self.ResolvePrefix(
        queue, prefix, timestamp=DataStore.ALL_TIMESTAMPS):
      task = rdf_flows.GrrMessage.FromSerializedString(serialized)
      task.leased_until = ts
      all_tasks.append(task)

    return all_tasks[:limit]