'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.
task_id: If an id is provided we only query for this id.
Returns:
A list of Task() objects.'

def Query(self, queue, limit=1, task_id=None):

    if isinstance(queue, rdf_client.ClientURN):
        queue = queue.Queue()
    if (task_id is None):
        prefix = self.TASK_PREDICATE_PREFIX
    else:
        prefix = utils.SmartStr(task_id)
    all_tasks = []
    for (_, serialized, ts) in self.data_store.ResolvePrefix(queue, prefix, timestamp=self.data_store.ALL_TIMESTAMPS, token=self.token):
        task = rdf_flows.GrrMessage.FromSerializedString(serialized)
        task.eta = ts
        all_tasks.append(task)
    all_tasks.sort(key=(lambda task: task.priority), reverse=True)
    return all_tasks[:limit]
