Beispiel #1
0
    def __init__(self):
        super().__init__()

        self._store = InMemoryStore()

        # process and delete self.messages every minute
        self.cron = Cron()
        self.cron.add(call=self._archive)
        self.cron.start()

        # publish a summary of all cancer messages grouped by minute and channel
        self.zmq_context = zmq.Context()
        self.pubsub_socket = self.zmq_context.socket(zmq.PUB)
        summary_socket = Config.get('monitor.socket.cancer_summary')
        self.pubsub_socket.bind(summary_socket)
        logger.info("bound publish socket to %s", summary_socket)

        # respond to live cancer requests
        self.cancer_socket = self.zmq_context.socket(zmq.REP)
        request_socket = Config.get('monitor.socket.cancer_request')
        self.cancer_socket.bind(request_socket)
        logger.info("bound cancer socket to %s", request_socket)

        # TODO: use asyncio
        t = threading.Thread(target=self._handle_cancer_request)
        t.daemon = True
        t.start()
        logger.info("started handle cancer request thread")