コード例 #1
0
ファイル: server.py プロジェクト: grossmj/gns3-server
    def _cleanup(self, signum=None, graceful=True):
        """
        Shutdowns any running module processes
        and adds a callback to stop the event loop & ZeroMQ

        :param signum: signal number (if called by a signal handler)
        :param graceful: gracefully stop the modules
        """

        # terminate all modules
        for module in self._modules:
            if module.is_alive() and graceful:
                log.info("stopping {}".format(module.name))
                self.stop_module(module.name)
                module.join(timeout=3)
            if module.is_alive():
                # just kill the module if it is still alive.
                log.info("terminating {}".format(module.name))
                module.terminate()
                module.join(timeout=1)

        ioloop = tornado.ioloop.IOLoop.instance()
        if signum:
            ioloop.add_callback_from_signal(self._shutdown)
        else:
            ioloop.add_callback(self._shutdown)
コード例 #2
0
ファイル: server.py プロジェクト: atassumer/gns3-server
    def _cleanup(self, signum=None, graceful=True):
        """
        Shutdowns any running module processes
        and adds a callback to stop the event loop & ZeroMQ

        :param signum: signal number (if called by a signal handler)
        :param graceful: gracefully stop the modules
        """

        # terminate all modules
        for module in self._modules:
            if module.is_alive() and graceful:
                log.info("stopping {}".format(module.name))
                self.stop_module(module.name)
                module.join(timeout=3)
            if module.is_alive():
                # just kill the module if it is still alive.
                log.info("terminating {}".format(module.name))
                module.terminate()
                module.join(timeout=1)

        ioloop = tornado.ioloop.IOLoop.instance()
        if signum:
            ioloop.add_callback_from_signal(self._shutdown)
        else:
            ioloop.add_callback(self._shutdown)
コード例 #3
0
ファイル: ws.py プロジェクト: bryceweiner/RZRoad
    def queue_response(self, response):
        ioloop = tornado.ioloop.IOLoop.instance()

        def send_response(*args):
            self._send_response(response)

        try:
            # calling write_message or the socket is not thread safe
            ioloop.add_callback(send_response)
        except:
            logging.error("Error adding callback", exc_info=True)
コード例 #4
0
    def __init__(self, ioloop, address):
        self.address = address
        self._topics = {}
        self._subscribers = []
        self.ioloop = ioloop

        def callback():
            s = ctx.socket(zmq.PUB)
            self.stream = zmq.eventloop.zmqstream.ZMQStream(s, io_loop=ioloop)
            self.stream.bind(self.address)
            self.debug('start publisher on %s', self.address)

        ioloop.add_callback(callback)
コード例 #5
0
    def __init__(self, ioloop, address):
        self.address = address
        self.dispatch_table = {}
        self.ioloop = ioloop

        def callback():
            s = ctx.socket(zmq.SUB)
            self.stream = zmq.eventloop.zmqstream.ZMQStream(s, io_loop=ioloop)
            self.stream.on_recv(self.dispatch)
            self.stream.connect(self.address)
            self.debug('start subscriber on %s', self.address)

        ioloop.add_callback(callback)