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)
def emit(event, data=None, persist=True, project_id=None): """ 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). """ if not data: data = {} if project_id is not None: data["project_id"] = project_id data = fields.serialize_dict(data) publisher_store.publish(event, data) if persist: save_event(event, data, project_id=project_id) # move to listen_event for avoid to refresh Zou after an update try: event_handlers.listen_event_task.delay(event, data) except Exception: current_app.logger.error("Error handling event", exc_info=1)
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)
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)