def collect_events(e, t, p):
    """
    Collect task waiting in the queue and store event in the database.
    """
    collection = None
    try:
        collection = models.get_mongo_collection()
        models.save_event(collection, e, t, p)

    finally:
        if collection:
            try:
                collection.connection.close()
            except:
                pass
def collect_events(e, t, p):
    """
    Collect task waiting in the queue and store event in the database.
    """
    collection = None
    try:
        collection = models.get_mongo_collection()
        models.save_event(collection, e, t, p)

    finally:
        if collection:
            try:
                collection.connection.close()
            except:
                pass
示例#3
0
def collect_events():
    """
    Collect all events waiting in the queue and store them in the database.
    """
    consumer = None
    collection = None
    try:
        consumer = _get_carrot_object(Consumer, queue=settings.QUEUE)
        collection = models.get_mongo_collection()

        for message in consumer.iterqueue():
            e, t, p = message.decode()
            models.save_event(collection, e, t, p)
            message.ack()

    finally:
        _close_carrot_object(consumer)
        if collection:
            try:
                collection.connection.close()
            except:
                pass