Пример #1
0
    def start(self):
        # Start default writer and reader
        CspZmqNode.start(self)

        # Create sockets
        xpub_out = self._context.socket(zmq.XPUB)
        xsub_in = self._context.socket(zmq.XSUB)
        xpub_out.bind('ipc:///tmp/zmqipcin')
        xsub_in.bind('ipc:///tmp/zmqipcout')

        s_mon = None
        if self.monitor:
            # Crate monitor socket
            s_mon = self._context.socket(zmq.PUB)
            s_mon.bind('tcp://*:{}'.format(self.mon_port_hub))

        if self.console:
            self.console_hub()

        # Start ZMQ proxy (blocking)
        try:
            zmq.proxy(xsub_in, xpub_out, s_mon)

        except KeyboardInterrupt as e:
            print("Main:", e)

        finally:
            # print("Closing due to", e)
            xsub_in.setsockopt(zmq.LINGER, 0)
            xsub_in.close()
            xpub_out.close()
            if s_mon:
                s_mon.close()

            self.stop()
Пример #2
0
 def start(self):
     CspZmqNode.start(self)
     self._predict_th = self.predict_reader()