

@classmethod
def ClaimNotificationsForCollection(cls, token=None, start_time=None, lease_time=200, collection=None):
    'Return unclaimed hunt result notifications for collection.\n\n    Args:\n      token: The security token to perform database operations with.\n\n      start_time: If set, an RDFDateTime indicating at what point to start\n        claiming notifications. Only notifications with a timestamp after this\n        point will be claimed.\n\n      lease_time: How long to claim the notifications for.\n\n      collection: The urn of the collection to find notifications for. If unset,\n        the earliest (unclaimed) notification will determine the collection.\n\n    Returns:\n      A pair (collection, results) where collection is the collection that\n      notifications were retrieved for and results is a list of tuples (id,\n      timestamp, suffix) where id identifies the notification within the queue\n      and (stimestmp, suffix) identifies the GrrMessage within the result\n      collection.\n\n    '

    class CollectionFilter(object):

        def __init__(self, collection):
            self.collection = collection

        def FilterRecord(self, notification):
            if (self.collection is None):
                self.collection = notification.result_collection_urn
            return (self.collection != notification.result_collection_urn)
    f = CollectionFilter(collection)
    results = []
    with aff4.FACTORY.OpenWithLock(RESULT_NOTIFICATION_QUEUE, aff4_type='HuntResultQueue', lease_time=300, blocking=True, blocking_sleep_interval=15, blocking_lock_timeout=600, token=token) as queue:
        for (record_id, value) in queue.ClaimRecords(record_filter=f.FilterRecord, start_time=start_time, timeout=lease_time, limit=100000):
            results.append((record_id, value.timestamp, value.suffix))
    return (f.collection, results)

dataset/ETHPy150Open google/grr/grr/lib/hunts/results.py HuntResultQueue.ClaimNotificationsForCollection/original