Exemplo n.º 1
0
def emit(event, data={}, persist=True):
    """
    Emit an event which leads to the execution of all event handlers registered
    for that event name.
    It publishes too the event to other services
    (like the realtime event daemon).
    """
    event_handlers = handlers.get(event, {})
    data = fields.serialize_dict(data)
    publisher_store.publish(event, data)
    if persist:
        save_event(event, data)

    from zou.app.config import ENABLE_JOB_QUEUE

    for func in event_handlers.values():
        if ENABLE_JOB_QUEUE:
            from zou.app.stores.queue_store import job_queue

            job_queue.enqueue(func.handle_event, data)
        else:
            try:
                func.handle_event(data)
            except Exception:
                current_app.logger.error("Error handling event", exc_info=1)
Exemplo n.º 2
0
def emit(event, data={}):
    """
    Emit an event which leads to the execution of all event handlers registered
    for that event name.
    It publishes too the event to other services
    (like the realtime event daemon).
    """
    event_handlers = handlers.get(event, {})
    publisher_store.publish(event, data)

    from zou.app import config
    for func in event_handlers.values():
        if config.ENABLE_JOB_QUEUE:
            from zou.app.stores.queue_store import job_queue
            job_queue.enqueue(func.handle_event, data)
        else:
            func.handle_event(data)
Exemplo n.º 3
0
def emit(event, data={}):
    """
    Emit an event which leads to the execution of all event handlers registered
    for that event name.
    It publishes too the event to other services
    (like the realtime event daemon).
    """
    event_handlers = handlers.get(event, {})
    data = fields.serialize_dict(data)
    publisher_store.publish(event, data)
    save_event(event, data)

    from zou.app.config import ENABLE_JOB_QUEUE
    for func in event_handlers.values():
        if ENABLE_JOB_QUEUE:
            from zou.app.stores.queue_store.job_queue import enqueue
            enqueue(func.handle_event, data)
        else:
            func.handle_event(data)